can this work for xml parsing as i have parse using json but it is not showing any response from web service. this is the status of webservice http/1.1 405 method not allowed 113ms
$j.ajax({
type: "GET",
async: false,
url: "Service1.asmx",
dataType: 'XML',
//contentType:'application/json',
success: function (data) {
$j.each(data, function (index, element) {
alert("Successful here: " + element);
//$j('#json').append("<li'>"+element+"</li>");
});
}
}).done(function (data) {
console.log(data);
alert("XML Data: " + data);
});
Use your method name in the url
parameter of ajax as eg: url: "Service.asmx/ConversionRate"
And if you are calling a webservice which is in different domain Eg: Your .js file in which you are writing ajax function is in www.abc.com
and you are calling a web service in www.xyz.com
(i.e) cross domain call, then you need to use server-routed proxy as shown below or use jsonp as cross domain call is not allowed by browsers.
var url = 'http://www.webservicex.net/Service1.asmx/ConversionRate;
var yql = 'http://query.yahooapis.com/v1/public/yql?q=' + encodeURIComponent('select * from xml where url="' + url + '"') + '&format=json&callback=?';
$j.ajax({
type: "GET",
async: false,
url: yql,
dataType: 'XML',
//contentType:'application/json',
success: function (data) {
if(data.query.results){
var result = data.query.results.double.content.replace(/<script[^>]*>[\s\S]*?<\/script>/gi, '');
$j.each(result, function (index, element) {
alert("Successful here: " + element);
//$j('#json').append("<li'>"+element+"</li>");
});
}
}
});
Use either success
or done
function, as both of them serve the same purpose.
And if you are using service from the same domain then the above said server-routed proxy not needed. Then the code will be as follows.
$j.ajax({
type: "GET",
async: false,
url: "Service1.asmx/GetConversion",
dataType: 'XML',
//contentType:'application/json',
success: function (data) {
$j.each(data, function (index, element) {
alert("Successful here: " + element);
//$j('#json').append("<li'>"+element+"</li>");
});
}
});