Andrew Bellamy

caffeine + nicotine = asp.net (c#), sql, php goodness
along with the standard web tech thrown in

mooTools Request.JSON

commentNo Comments personAndy folderCategories: code tagTags: 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();

your go