How do I send a cross-domain POST request via JavaScript?
Notes - it shouldn\'t refresh the page, and I need to grab and parse the response afterwards.
Keep it simple:
cross-domain POST:
use crossDomain: true,
shouldn't refresh the page:
No, it will not refresh the page as the success
or error
async callback will be called when the server send back the response.
$.ajax({
type: "POST",
url: "http://www.yoururl.com/",
crossDomain: true,
data: 'param1=value1¶m2=value2',
success: function (data) {
// do something with server response data
},
error: function (err) {
// handle your error logic here
}
});