jackjohnson44
asked on
convert ajax xmlhttprequest to jquery ajax
Hi, I am trying to convert the following code to jquery, but I am having issues. This uses cross site scripting, but I changed the setting on my browser. I can successfully use the non jquery code.
Ajax=new XMLHttpRequest();
Ajax.open('POST', url, true);
Ajax.setRequestHeader("Con tent-type" , "application/x-www-form-ur lencoded") ;
Ajax.send(data);
Here is what I currently have:
jQuery.ajax({
url: loginUrl,
contentType: "text/html; charset=Windows-1256",
dataType: "JSONP",
async: true,
success: function (responseText, status) {
alert("success" + responseText);
},
error: function (xhr, ajaxOptions, thrownError) {
responseText("error=" + xhr.status + "=" + thrownError);
}
Ajax=new XMLHttpRequest();
Ajax.open('POST', url, true);
Ajax.setRequestHeader("Con
Ajax.send(data);
Here is what I currently have:
jQuery.ajax({
url: loginUrl,
contentType: "text/html; charset=Windows-1256",
dataType: "JSONP",
async: true,
success: function (responseText, status) {
alert("success" + responseText);
},
error: function (xhr, ajaxOptions, thrownError) {
responseText("error=" + xhr.status + "=" + thrownError);
}
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
please provide a link to a simple page which reside on your site
ASKER
Your answer will work. I had an issue due to cross site scripting. Thanks!
ASKER
This is what I have:
var postData = {};
postData["source"] = source;
var loginUrl = url + "LogIn?source=" + source + "&version=" + version;
jQuery.ajax({
url: loginUrl,
//dataType: "xml",
data: postData,
async: true,
type: "POST",
success: function (responseText, status) {
alert("ASDF");
},
error: function (xhr, ajaxOptions, thrownError) {
responseText("xhr.status="
}
});