I am making this simple get request using jquery ajax:
$.ajax({
url: \"https://app.asana.com/-/api/0.1/workspaces/\",
type: \'GET\',
success: functio
i think the problem is that there is no data in the success-function because the request breaks up with an 401 error in your case and thus has no success.
if you use
$.ajax({
url: "https://app.asana.com/-/api/0.1/workspaces/",
type: 'GET',
error: function (xhr, ajaxOptions, thrownError) {
alert(xhr.status);
alert(thrownError);
}
});
there will be your 401 code i think (this link says so)
var settings = {
"async": true,
"crossDomain": true,
"url": "<your URL Here>",
"method": "GET",
"headers": {
"content-type": "application/x-www-form-urlencoded"
},
"data": {
"username": "user@company.com",
"password": "12345678"
}
}
$.ajax(settings).done(function (response) {
console.log(response);
});
It seems to me, this is a cross-domain issue since you're not allowed to make a request to a different domain.
You have to find solutions to this problem: - Use a proxy script, running on your server that will forward your request and will handle the response sending it to the browser Or - The service you're making the request should have JSONP support. This is a cross-domain technique. You might want to read this http://en.wikipedia.org/wiki/JSONP
You can make AJAX requests to applications loaded from the SAME domain and SAME port.
Besides that, you should add dataType JSON
if you want the result to be deserialized automatically.
$.ajax({
url: "https://app.asana.com/-/api/0.1/workspaces/",
type: 'GET',
dataType: 'json', // added data type
success: function(res) {
console.log(res);
alert(res);
}
});
http://api.jquery.com/jQuery.ajax/
var dataString = "flag=fetchmediaaudio&id="+id;
$.ajax
({
type: "POST",
url: "ajax.php",
data: dataString,
success: function(html)
{
alert(html);
}
});