mooTools Request.JSON
No Comments
Andy
Categories:
code
Tags:
JavaScript, mooTools
I had a look at mooTools documentation for Request.JSON and managed to confuse myself
It took me four attempts to get the following code right. The code calls a webservice created in ASP.net C#.
code
new Request.JSON({
headers: { 'Accept': 'application/json', 'X-Request': 'JSON', 'Content-Type': 'application/json' },
urlEncoded: false,
url: "WEBSERVICE URL", // webservice/method
method: 'post',
// The values on the left hand side of the colon must match that of the parameters of the webservice
data: JSON.encode({ value1 : $('VALUE1').get('value'), value1 : 'VALUE2' }),
onSuccess: function (responseJSON, responseText) {
/*
DO SOMETHING
*/
}
}).send();