I am currently using $.ajax to post to a Perl file that queries a webservice and returns XML. Running the Perl via command line confirms that XML is being returned with Content-Type: application/xml. However, regardless if I set the dataType parameter to "xml", "XML" or just use jQuery's intelligent guess, it appears that I am not getting any data returned to my function at all.
I've tried using the full $.ajax notation and the simplified $.get notation as follows:
$.get(
'http://internalperlsite/addLocation.pl',
$("#addLocationForm").serialize(),
function(data, status, xmlhttp){
if (status == "success"){
alert('Location added.');
window.location.href = window.location.href;
}
}
);
and...
$.ajax({
async: true,
data: $("#addLocationForm").serialize(),
type: "GET",
url: "http://internalperlsite/addLocation.pl",
success: function(data, status, xmlhttp){
if (status == "success"){
alert("Location added.");
window.location.href = window.location.href;
}
},
error: function(xhr, ajaxOptions, thrownError){
$("body").append("<div class='error'>Error<hr>"+xhr.status+"<br>"+thrownError+"</div>");
},
complete: function(){
}
});
I have also tried using JQuery to perform a "GET" directly to the webservice which returns XML by default and still I get no data returned to my function.
$.ajax({
async: true,
type: "GET",
dataType: "XML",
beforeSend: function(req) {
req.setRequestHeader('Authorization', auth);
},
url: url,
success: function(data, success, xmlhttp){
$(data).find("ProvisionedLocations").each(function(){
alert($(this).find("callername").text());
});
},
error: function(xhr, ajaxOptions, thrownError){
$("body").append("<div class='error'>Error<hr>"+xhr.status+"<br>"+thrownError+"</div>");
},
complete: function(){
$("#loading").hide();
}
});
Although I doubt it's browser-related, I have confirmed this in both Chrome (5.0.375) and Firefox (3.6.3).
Anyone else experiencing this issue?