sugarcrm/sugarcrm_dev — pull request #123 by BjoernSchotte (2012-09-23 14:19:05+00:00)
Title: added JSONP support, ie. JSON cross-domain calls from outside with i.e. ...

...jQuery.

This small patch adds JSONP callback support when calling the REST interface from external JavaScript, ie. with jQuery:

$.ajax({
url: config.endpointURL + "?jsoncallback=?",
data: { method: methodName, input_type: "JSON", response_type: "JSON", rest_data: JSON.stringify(params) },
dataType: 'jsonp',
success: callbackFunction,
error: failFunction
});

jQuery creates a random jsoncallback GET parameter as in the JSONP standard and the server wraps a JS function call around the JSON response. jQuery (and other libraries) then include the URL with a