Reputation: 125
I need to post data to another server using jquery.
Here is the code i am using
$.ajax({
url:"https://www.thewiseagent.com:443/secure/webcontactAllFields.asp",
type:'POST',
data:"ID=" + $ID
+ "&Source=" + $Source
+ "¬ifyCc=" + $notifyCc
+ "¬ifyBcc=" + $notifyBcc
+ "&noMail=" + $noMail
+ "&CFirst=" + $first
+ "&CLast=" + $last
+ "&Phone=" + $Phone
+ "&Fax=" + $Fax
+ "&CEmail=" + $CEmail
+ "&Message=" + $message,
success: function() {
//window.location.href = "http://www.petlooza.com";
}
});
i got error (302 object moved) in case of firefox/chorme although data is inserting.. but in case of IE data is not entering in external database. In IE i got a Access denied error.
Can anyone have alternative?
I have tried with json and jsonp still same error.
$.ajax({
type: "POST",
url: "https://www.thewiseagent.com:443/secure/webcontactAllFields.asp",
data: dataString,
dataType: "jsonp",
success: function(data) {
}
});
Upvotes: 2
Views: 4196
Reputation: 3870
You have a crossdomain problem. Try using jsonp:
$.ajax({
url:"https://www.thewiseagent.com:443/secure/webcontactAllFields.asp",
type:'POST',
dataType: "jsonp",
data:"ID="+$ID+"&Source="+$Source+"¬ifyCc="+$notifyCc+"¬ifyBcc="+$notifyBcc+"&noMail="+$noMail+"&CFirst="+$first+"&CLast="+$last+"&Phone="+$Phone+"&Fax="+$Fax+"&CEmail="+$CEmail+"&Message="+$message,
success: function(data) {
//window.location.href = "http://www.petlooza.com";
}
});
Upvotes: 0
Reputation: 76870
If you want to use $.ajax() and make a request to another domain you must set crossDomain option to true as stated in the documentation
$.ajax({
url:"https://www.thewiseagent.com:443/secure/webcontactAllFields.asp",
type:'POST',
crossDomain: true,
data:"ID="+$ID+"&Source="+$Source+"¬ifyCc="+$notifyCc+"¬ifyBcc="+$notifyBcc+"&noMail="+$noMail+"&CFirst="+$first+"&CLast="+$last+"&Phone="+$Phone+"&Fax="+$Fax+"&CEmail="+$CEmail+"&Message="+$message,
success: function() {
//window.location.href = "http://www.petlooza.com";
}
});
Upvotes: 1
Reputation: 18440
You could make an AJAX request to a php script on your own server, which then gets the information from the other server and returns it to you jQuery. I can't think of any other way at the moment.
Upvotes: 0