jquery - .success UncaughtSyntaxError: Unexpected identifier -


i baffled why receiving 'unexpected identifier' error code. thing changed url.

i working on project , while waiting project partner setup heroku, diverted fake api.

here's code:

$('#username-submit').click(function() {    var userlinks = $('.user-links')    console.log('test');    $.ajax({      method: 'get', //this git request      url: 'http://jsonplaceholder.typicode.com' //link api created      beforesend: function(xhr) {        xhr.setrequestheader('authorization', 'user name'); //takes username , authorizes        datatype: 'json',          .success(function(data) {            console.log(data);          })      }    })  });
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>

you've got beforesend handler little bit wrong, or rather brackets , commas.

this should fix it:

$('#username-submit').click(function() {    var userlinks = $('.user-links');    console.log('test');    $.ajax({      method: 'get', //this git request      url: 'http://jsonplaceholder.typicode.com', //link api created      beforesend: function(xhr) {        xhr.setrequestheader('authorization', 'user name'); //takes username , authorizes      },      datatype: 'json',      success: function(data) {        console.log(data);      }    });  });

it seems you're not using userlinks.

and frank, doubt "only url changed" - original version you've posted never have worked in first place.


Comments

Popular posts from this blog

wordpress - (T_ENDFOREACH) php error -

Export Excel workseet into txt file using vba - (text and numbers with formulas) -

Using django-mptt to get only the categories that have items -