A problem arose when trying to consume a web service xml from JS with ajax since it has authentication prior to the delivery of information and I can not inspect the form of the credentials requested.
try the following:
function webservice() {
$.ajax({
url: "urlwebserv",
type: "Post",
data: { username: "username", password: "password" },
dataType: 'xml',
success: function (data) {
$(data).find("Data").each(function () {
$(this).find("id").text();
});
},
error: function () {
alert("Do!");
}
});
}
tbn try this:
function webservice() {
$.ajax({
url: "urlwebserv",
type: "Post",
username: "username",
password: "password",
dataType: 'xml',
success: function (data) {
$(data).find("Data").each(function () {
$(this).find("id").text();
});
},
error: function () {
alert("Do!");
}
});
}
The question is: can ajax enter a web service that requests authentication by form? and then access the information delivered from an xml
browser errors:
Failed to load resource: the server responded to a status of 401 (Unauthorized).
Failed to load urlwebsrv: Response to preflight request does not pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin ' link ' is therefore not allowed access. The response had HTTP status code 401.
please help.