i have a web service in a server, and i could connect web service from any browser in remote machine or host machine. But i couldn’t access the web service using ajax call in javascript, showing 403 forbidden error. I ran the script from the server itself. Below is the code i used.
$(‘div’).live(‘pageshow’,function(event, ui){
var username = 'vijay';
var password = 'vijay';
var domain = '';
var windowsuser = false;
// var dataObject = {};
// dataObject = {Username:username,Password:password,Domain:domain,WindowsUser:windowsuser};
$('#login').click(function(){
$.ajax({
type: "POST",
url: "http://xxx.xxx.x.xx/Y_NAME/REST/session.aspx",
data: ({Username:username,Password:password,Domain:domain,WindowsUser:windowsuser}),
// contentType: "application/x-www-form-urlencoded",
cache: false,
dataType: "json",
timeout: 5000,
success: onSuccess
});
});
$("#resultLog").ajaxError(function(event, request, settings, exception) {
$("#resultLog").html("Error Calling: " + settings.url + "<br />HTTP Code: " + request.status);
});
function onSuccess(data)
{
//$("#resultLog").html("Result: " + data);
console.log(data[0].Name);
}
Here , after calling web service, it has to return JSON data, but it didn’t return anything. In firebug, inside the function onSucess, it shows ‘null’ for data.
Do i miss anything here? Y does it show ‘403’ forbidden error? Since i’m calling the scripts from the server where the web service located, i think its not cross domain issue. I’m using this in Jquery mobile. Help needed. Thanks in advance.
I figured it.. There was problem with URL.