Javascript - Ajax Jquery Simple Get Request - Stack Overflow
Javascript - Ajax Jquery Simple Get Request - Stack Overflow
We changed our privacy policy. Read more.
28 $.ajax({
url: "https://app.asana.com/-/api/0.1/workspaces/",
type: 'GET',
success: function(res) {
console.log(res);
alert(res);
6 }
});
{"status":401,"error":"Not Authorized"}
Share Improve this question edited Oct 26 '18 at 7:20 asked Feb 13 '12 at 22:52
Follow kartikmaji 0xSina
914 7 21 19.1k 29 128 247
@KaiQing, That isn't the problem here at all. Otherwise, the success handler wouldn't be called.
Besides, the example response isn't a JSONP response.
– Brad
Feb 13 '12 at 22:57
@PragmaOnce, Check your headers with a packetsniffer, such as Wireshark. I suspect you'll find some
differences between what is being sent from the browser, and with the AJAX call.
– Brad
Feb 13 '12 at
22:58
You can make AJAX requests to applications loaded from the SAME domain and SAME port.
24 Besides that, you should add dataType JSON if you want the result to be deserialized
automatically.
$.ajax({
"https://app.asana.com/-/api/0.1/workspaces/" Sign up
type: 'GET',
success: function(res) {
console.log(res);
alert(res);
});
http://api.jquery.com/jQuery.ajax/
It seems to me, this is a cross-domain issue since you're not allowed to make a request to a
different domain.
10
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
Share Improve this answer edited Aug 25 '19 at 3:56 answered Feb 13 '12 at 23:06
Follow viveknaskar Joao Almeida
1,662 1 13 27 912 2 6 17
3 $.ajax
({
type: "POST",
url: "ajax.php",
data: dataString,
success: function(html)
alert(html);
});
Share Improve this answer edited Dec 5 '13 at 13:20 answered Dec 5 '13 at 12:53
Follow Nunser user3070157
4,494 8 22 35 55 1 2
3 POST and GET is a different HTTP methods, please read some information about HTTP protocol
– bmalets
Apr 3 '20 at 20:44
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.
1
Join Stack
if youOverflow
use to learn, share knowledge, and build your career. Sign up
https://stackoverflow.com/questions/9269265/ajax-jquery-simple-get-request 2/3
28/09/2021, 17:49 javascript - ajax jquery simple get request - Stack Overflow
$.ajax({
url: "https://app.asana.com/-/api/0.1/workspaces/",
type: 'GET',
alert(xhr.status);
alert(thrownError);
});
there will be your 401 code i think (this link says so)
Share Improve this answer edited May 23 '17 at 11:54 answered Apr 2 '13 at 15:04
Follow Community Bot Matthew Fisher
1 1 173 1 15
var settings = {
"async": true,
1 "crossDomain": true,
"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);
});
Join Stack Overflow to learn, share knowledge, and build your career. Sign up
https://stackoverflow.com/questions/9269265/ajax-jquery-simple-get-request 3/3