Getting error while calling webrservice which is on differnt

Jul 19 2015 7:41 AM
Hello everyone,
i need your help.i am getting error  cross domain is not possible 
 
 
javascript code:
function ValidateUser()
{
var inputName= $('#inputName').val();
var inputPassword= $('#inputPassword').val();
var LoginStatus="false";
if(inputName==""||inputPassword=="")
{
alert('Plese Fill UserName and Password');
}else
{
$.ajax({
type: "GET",
url: "http://localhost/QM3013July2015__/OAuth2/QuestManager/Token?grant_type=password&client_id=QMMobile&client_secret=123&username="+inputName+"&password="+inputPassword,
dataType: "json",
success: function (data) {
$('#hdnAccessCode').val(data.access_token);
},
error: function(data){
alert('You are Not Authorized to view this page');
$('#hdnAccessCode').val('');
}
});
}
callOtherWebservices($('#hdnAccessCode').val());
return false;
}
function callOtherWebservices(access_token)
{
var token =access_token;
var RESOURCE_ENDPOINT="https://localhost/QM3013July2015__/jsonapi/QuestManager/HomePageDetails";
//var RESOURCE_ENDPOINT="http://10.131.8.51/XamarinEnv1/jsonapi/QuestManager/HomePageDetails";
//var callbackName1=jsonp(RESOURCE_ENDPOINT, function(data) {alert(data);});
$.ajax({
url:RESOURCE_ENDPOINT,
dataType: "jsonp",
beforeSend: function (xhr) {
xhr.setRequestHeader('Authorization', "Bearer " + token);
//xhr.setRequestHeader('Authorization', "OAuth" + token);
xhr.setRequestHeader('Accept',"application/json");
xhr.setRequestHeader('Access-Control-Allow-Origin',"*");
xhr.setRequestHeader('Access-Control-Allow-Methods',"*");
//xhr.setRequestHeader('Access-Control-Allow-Credentials',"false");
},
success: function (response) {
str=response;
},
error: function( response ) {
alert( "ERROR: " + JSON.stringify );
}
});
}
 

Answers (4)