$.ajax({
beforeSend: function(req) {
req.setRequestHeader("Accept", "text/xml");
},
type: "GET",
url: "[proper url]",
contentType: "text/plain; charset=utf-8",
dataType: ($.browser.msie) ? "text" : "xml",
username: '---',
password: '-------',
success: function(data) {
var xml;
if (typeof data == "string") {
alert("Data is string:" + data);
xml = new ActiveXObject("Microsoft.XMLDOM");
xml.async = false;
xml.loadXML(data);
} else {
xml = data;
alert("Data is not string:" + $(xml).text());
}
// Returned data available in object "xml"
//alert("Status is: " + xml.statusText);
$("#ingest_history").html($(xml).text());
}
});
If you never view this kind of setting than this is time for you read this article
why set this setting ?
ans is here :
beforeSend : A pre-request callback function that can be used to modify the jqXHR (in jQuery 1.4.x, XMLHTTPRequest) object before it is sent. Use this to set custom headers.
Type : "get" or "post" set HTTPRequest type.if u set "get" than ur data is view in url.so my advice is use "Post"
contentType: if you set contentType to plain/text than your result allways accept plain/text
dataType: what kind of data you want ? xml , html ,text
success: call user define function if your ajax request successfully executed
beforeSend : A pre-request callback function that can be used to modify the jqXHR (in jQuery 1.4.x, XMLHTTPRequest) object before it is sent. Use this to set custom headers.
Type : "get" or "post" set HTTPRequest type.if u set "get" than ur data is view in url.so my advice is use "Post"
contentType: if you set contentType to plain/text than your result allways accept plain/text
dataType: what kind of data you want ? xml , html ,text
success: call user define function if your ajax request successfully executed