Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Several ways to accomplish this. Like above, look at the .NET PageMethod/WebMethods. It will show you how to build the WebMethods and call them from Javascript.</p> <p>I've been switching away from .NET pre-built stuff and going with straight jQuery ajax calls. It's the same thing, but using jQuery you have a little more control over the call and what it returns.</p> <pre><code>jQuery.ajax({ type: "POST", url: "edit.aspx/yourmethodname", data: "{yourmethodparam:" + somevar + "}", contentType: "application/json; charset=utf-8", dataType: "json", success: function(response) { alert(response.d); } error: function(err, response) { alert("error"); } }); </code></pre> <p>It's more complex, but you get more control over what type of object is returned, JSON or text. </p> <p>Remember, response.d the "d" is the JSON object if you decide to return more then just a simple type, like string or integer. You can return objects like lists and such. These will be converted to JSON objects. If it were a simple type like an integer, then just 'response' would be the value.</p> <p>If you decide to go more complex and use JSON return objects, watch the 'datatype' property, sometimes I found .NET returning string objects that had to be converted into JSON using, json2.js file - <a href="http://www.json.org/js.html" rel="nofollow noreferrer">http://www.json.org/js.html</a>. It threw me for a loop for a long time. It's a good site that will explain JSON, as that's what the PageMethod/WebMethods are really using.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload