Need some explanation about MS Ajax using PageMethods
Posted
by
Ahmed Said
on Stack Overflow
See other posts from Stack Overflow
or by Ahmed Said
Published on 2011-01-16T15:28:26Z
Indexed on
2011/01/16
15:53 UTC
Read the original article
Hit count: 206
I have a project that uses PageMethods to call functions on the server. The server functions (written in C#) return the values as array of strings, without doing any kind of serialization and in the client side (from Js) the accessing of the return values is by using static variable called arguments. I found that sometimes for some users (cases are not repro) sometimes an exception occured
"WebServiceFailedException the server method 'Foo' returned invalid data. the 'd' property is missing from JSON."
Some searching on google I found that people are serializing the return values using DataContractJsonSerializer class and in js accessing the return value using one of the callback function Example:
function OnRequestComplete(result, userContext, methodName) {
var Person = eval('(' + result + ')'); alert(Person.Forename);
alert(Person.Surname); }
So is the first technique is correct? or what?
© Stack Overflow or respective owner