cancel
Showing results for 
Search instead for 
Did you mean: 

I have been trying to do a cross domain ajax request using JSONP

Former Member
0 Kudos

Code is something like this:

var url = 'https://www.google.com/?q=video&wt=json&json.wrf=callback=getJSON'; $.ajax({ url : url, jsonpCallback : 'getJSON', contentType : "application/json", dataType : 'jsonp', success : function(data, textStatus, jqXHR) { alert("Happy"); online = "true"; }, error: function(e) { alert("Sad"); alert(e); online = "false"; } });

I am getting a exception as below:

uncaught SyntaxError: Unexpected token <

Anyone can please help me out

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

The response from your url is actually an HTML and that's the reason you are running into Syntax errors.

You need to check your api end point. It doesn't seem right.

If you are just trying out things, please feel free to use some open sourced API end points. One such example below.

var url = 'http://freegeoip.net/json/github.com';

BTW, this is not related to SAP UI5.