0
votes

I have used Ext.data.JsonP.request and get 'Uncaught SyntaxError: Unexpected token <' here is a part of code:

 Ext.data.JsonP.request({
           url: url,
           scope: this,
           callback: function(data) {

           },

How can I parse it?

1
Could you use browser dev tool(press F12 in chrome/firefox) to check what is the response from server? I met this error before because the server encounter 500 error and reply a html page - yellowB
Yes it's reply a html page - Vahe Akhsakhalyan
What data do you expect? - yellowB
Actually, I want to check 'X-Frame-Options' header for that url - Vahe Akhsakhalyan

1 Answers

0
votes

Your request fails because the response data is not valid JavaScript. Also: A JSONP request can never be used to read the response headers.

This is because a JSONP request isn't actually a new type of Request, but instead it's just a script tag inserted on-the-fly into the head part of the DOM.

In order to get the headers of an HTTP resource, best use a standard Ext.AJAX request and make sure the resource you want to access will send proper Access-Control-Allow-Origin headers. For more details about this look up Cross-origin resource sharing and the Same-origin policy.