Rod Rod - 4 months ago 19
Ajax Question

Why is my parameter null when I try to pass object using MS AJAX PageMethods

I tried the following snippet as well:

PageMethods.MyMethod(JSON.stringify(person), OnMyMethodComplete);

Client markup:

<script type="text/javascript">
var person = { firsName: "World" };
function test() {
PageMethods.MyMethod(person, OnMyMethodComplete);

function OnMyMethodComplete(result) { alert(result); }

window.onload = function () {


public static string MyMethod(Person p)
return "Hello " + p.FirstName;

enter image description here

Rod Rod

I was defining var Person in client code, but looking for var p on the server-side.