1

I am getting the error: Uncaught SyntaxError: Unexpected token <

I am only experiencing this problem with Google Trend URL. Other URLs are working fine.

function ajaxfun(){

  $.ajax({
    type: 'GET',
    url: 'http://www.google.com/trends/fetchComponent?content=1&hl=en-US&q=fever&cid=TIMESERIES_GRAPH_0&export=3&US&cat=0-45', 
    dataType :"jsonp",
    jsonp: false,
    crossDomain: true,
    error: function(data) {
      console.log('error', data);
    },
    success: function(data) {
      console.log('success', data);
    },
    complete: function() {
      console.log('done');
    }
  });
}
1
  • 1
    What does data contain? Commented Mar 29, 2013 at 12:10

2 Answers 2

1

You are not actually receiving a json object. It says,

<div id="report">
<div class="timeBandTitle">An error has been detected</div>
<div class="timeBandSubTitle">This page is currently unavailable. Please try again later.<br/> Please make sure your query is valid and try again.<br/> If you're experiencing long delays, consider reducing your comparison items.<br/> Thanks for your patience.</div>

Demo Inspect with developer tools and see it in Network tab.

Sign up to request clarification or add additional context in comments.

1 Comment

I have't used trends api but found this link .. stackoverflow.com/questions/7805711/…. You might find something useful here.
0

jQuery by default prevents caching of jsonp by appending &_={timestamp} at the end of the url. It causes the error. Add cache:true to prevent it.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.