Getting “Uncaught SyntaxError: Unexpected token :” while accessing JSON from external URL

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP

Getting “Uncaught SyntaxError: Unexpected token :” while accessing JSON from external URL



I am trying to access JSON data from an external URL.



I am using JSONP and here is my code :


$.ajax(
url: 'https://myurl.com',
dataType: 'JSONP',
jsonpCallback: 'callback',
type: 'GET',
success: function (data)
console.log(data);
);



The status code is 200, even I can see the JSON from that URL but I am getting the error:



Uncaught SyntaxError: Unexpected token :



and unable to work with that JSON data



Can anyone help me to figure this out?





As the error states, the received JSON is invalid. If you generate that JSON yourself, use a proper function for encoding the JSON and feed it actual objects or arrays. Don't attempt to stitch it up yourself. If you don't generate that JSON yourself, you need to inform whoever is responsible for that API it's borked and wait for them to fix it.
– Andrei Gheorghiu
2 days ago






The JSON is absolutely fine .
– Sayandip Ghatak
2 days ago





may you please write json resonse
– Mohammad
2 days ago





What you believe regarding that JSON contradicts with what the manufacturers of the browser you are using believe. I'm a bit biased. Based on experience, I tend to assume they are right and you are wrong, but feel free to inform them of their erroneous implementation of JSON parser if you are absolutely sure you are right.
– Andrei Gheorghiu
2 days ago






Could you also include your callback() function?
– Andrei Gheorghiu
2 days ago



callback()









By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Comments

Popular posts from this blog

Executable numpy error

Trying to Print Gridster Items to PDF without overlapping contents

Mass disable jenkins jobs