Answer the question
In order to leave comments, you need to log in
Why doesn't want to parse JSON?
There is some API, you need to get a token.
I receive data:
function gettok2(){
var result;
$.ajax({
type: 'GET',
cache: false,
callbackParameter: 'callback',
async: false,
crossDomain: true,
dataType: 'jsonp',
url: "https://api.shipper.io/v1/login/key",
data:{ username:"xxxxxx",auth_key:"xxxxxxxxxxxxxxxxxxxx"},
success: function(data){
var r = $.parseJSON(data);
result = r.access_token;
console.log(r.access_token);
alert(r);
}
});
return result;
}
{"access_token":"gmZxervvZWL-qop3vS6d8qTwjamBk5QM"}
Answer the question
In order to leave comments, you need to log in
try
...
success: function(data){
var r = $.parseJSON(data);
result = r["access_token"];
console.log(r["access_token"]);
alert(r);
...
Your situation is similar to this
one . the problem is in the cross-site policies
Are you using jsonp? This means that in the success callback, data is already a normal js object and does not need to be parsed.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question