I need to make a method that does not reload the page and send the data to a server in another domain. But I'm having problems with XMLHttpRequest
. Does anyone know any method to do this and can send the data to the script PHP that is on the other server outside the domain?
This is the method I was trying to do:
$(function() {
$('#form1').submit(function(event){
event.preventDefault();
var nome = $("#Nome").val();
var email = $("#Email").val();
if (nome!='' & email!='') {
$.ajax({
type: "POST",
url: "Insert_blog_tricae2.php",
contentType: "application/json; charset=utf-8",
crossDomain : "true",
dataType: "jsonp",
asynch: true,
data: {"Nome": nome, "Email":email},
success: function(retorno){
$('#resultado').html(nome+"<br>"+email).fadeIn();
$('#Nome').val('');
$('#Email').val('');
$('#resultado').fadeOut(10000);
}
});
} else {
$('#resultado').html('<center>Existem campos incompletos no formulário.<br> Favor preencher todos.</center>').show();
}
return false;
})
})