.NET Development
Gathering an object in CallbackHandler
Gravatar is a globally recognized avatar based on your email address. Gathering an object in CallbackHandler
  Craig Tucker
  All
  Jul 9, 2020 @ 03:12pm

Hi Rick,

I am trying to pass a json data object to a CallBackHandler and can't seem to make it happen. Can you please review and tell me what I need to do to hook up and process the object?

Thanks, Craig

Gravatar is a globally recognized avatar based on your email address. re: Gathering an object in CallbackHandler
  Rick Strahl
  Craig Tucker
  Jul 10, 2020 @ 01:07pm

The client call looks right, but you're not receiving the result type on the server. Create a parameter on the method with your SubscriberDelete type that should be deserialized into.

[CallbackMethod(...)]
public bool ServerDelete(SubscriberDelete model) 
{
}

Also, you should probably use ajaxJson() which makes the client call easier:

ajaxJson

It's in ww.jquery.js and it defaults to a POST operation:

ajaxJson(url, { id: value, name: "Rick" })
     .then( function(result) {
                 alert("Server result: " + result;
            })
     .error( function(error)  { alert("server request failed:  " + error.message); }

+++ Rick ---

© 1996-2020