Skip to main content

Fix cross domain in ajax request

Follow this sample ajax request

$.ajax({
   "type": 'POST',
   "url": url,
   "crossDomain": true,
   "data": params,
   "dataType": 'json',
   "async": false,
   "success": function(data){
done_fn(data, is_test);
   },
   "error": function (jqXHR) {
var data = $.parseJSON(jqXHR.responseText);
$("#results").text(data.message);
   }
});

The keys are crossDomain: true and async: false

Hope to help many people.

Comments