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
Post a Comment