How to overcome to the Cross Domain limitation in HTTP using Editor?
How to overcome to the Cross Domain limitation in HTTP using Editor?
arieldistefano
Posts: 4Questions: 0Answers: 0
I've tried to create a proxy in PHP, but the Editor Ajax call give me the JSON data transformed into www-form-url-encoded, so I can just Re-post the data from the PHP.
Do you have any example Allan about this?
Do you have any example Allan about this?
This discussion has been closed.
Replies
[code]Access-Control-Allow-Origin: http://example.com[/code]
If, however, you don't know the domain (or you're developing on localhost) then the header would have to be set to:
[code]Access-Control-Allow-Origin: *[/code]
In Editor you would use the 'ajax' option ( http://editor.datatables.net/options/#ajax ) to make an Ajax request with a JSONP data type - in the same way DataTables uses fnAjaxData (Editor simplifies a lot of the naming :-) ).
Allan
We solved yesterday creating a proxy PHP in our side and here the code with all the params (after a couple of hours we learned that "processData": false is needed to receive the POST objects as it is in PHP .
"ajax": function (method, url, data, successCallback, errorCallback) {
$.ajax( {
"type": "POST",
"url" : "../datasource/execute_action.php",
"data": JSON.stringify(data),
"contentType" : "application/json",
"dataType": 'json',
"processData": false,
"cache": false,
"success": function (json) {
//successCallback( json );
},
"error": function (xhr, error, thrown) {
//errorCallback( xhr, error, thrown );
}
} );