Rod Rod - 1 year ago 65
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
Answer Source

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

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download