0
I need to do a method that does not reload the page and send the data to a server on another domain. However I am having problems with the XMLHttpRequest
. Does anyone know any method to do this and be able to send the data to the script PHP that is on the other server outside the domain?
That’s 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;
})
})
the code is this:
– Rafael dos Santos
$(Function(){ $('#Form1'). Submit(Function(Event){ Event.preventDefault(); var name = $("#Name"). val(); var email = $("#Email"). val(); if (name!= '' & email!= ') { $. ajax({ type: "POST", url: "Insert.php", contenttype: "application/json; charset=utf-8", crossDomain : "true", dataType: "jsonp", asynch: true, date: {"Name": name, "Email":email}, Success: Function(return){ $('#result'). html(name+"<br>"+email). fadein(); $('#Name'). val('); $('#Email'). val('');
– Rafael dos Santos
What is the url for where you want to do ajax?
– Sergio
You want the address of the server I’m sending the request?
– Rafael dos Santos
Thanks for the help!
– Rafael dos Santos