Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9303773
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T23:33:51+00:00 2026-06-18T23:33:51+00:00

I am just trying to figure out the deferred api and have this nice

  • 0

I am just trying to figure out the deferred api and have this nice sample code going with the twitter search api:

var getTweets = function(q) {
    return $.ajax({
        url: 'http://search.twitter.com/search.json?q=' + encodeURIComponent(q),
        dataType: 'jsonp'
    })
};

var getTheDay = function(date){
    var date = new Date(date);
    return date.getDay();
}

var parseTweetData = function(data){
    $.each(data.results, function(index, tweet){
        console.log(tweet.text 
        + ' from ' + tweet.from_user_name 
        + ' at ' + getTheDay(Date.parse(tweet.created_at) * 1000));
    });
}

var parseError = function(error, xhr) {
    alert('failed')
};

$.when(getTweets(' martin')).then(parseTweetData, parseError);

Getting results back is just fine. The problem comes with the situation where twitter returns a 403 error.

I want to handle that error with my custom error handler but that doesn’t seem to be triggered at all. What am I doing wrong? Have I misunderstood the api? How do I write a proper ajax error handler request?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T23:33:53+00:00Added an answer on June 18, 2026 at 11:33 pm

    According to the $.ajax docs the error handler isn’t called for jsonp requests, so it probably wont call in a deferred either.

    error
    Type: Function( jqXHR jqXHR, String textStatus, String errorThrown )
    A function to be called if the request fails. The function receives three arguments: The jqXHR (in jQuery 1.4.x, XMLHttpRequest) object, a string describing the type of error that occurred and an optional exception object, if one occurred. Possible values for the second argument (besides null) are “timeout”, “error”, “abort”, and “parsererror”. When an HTTP error occurs, errorThrown receives the textual portion of the HTTP status, such as “Not Found” or “Internal Server Error.” As of jQuery 1.5, the error setting can accept an array of functions. Each function will be called in turn. Note: This handler is not called for cross-domain script and JSONP requests. This is an Ajax Event.

    you can try using a timeout to trigger an error callback, so basically we are giving the request some amount of time to be made and when the time expires we assume the request failed.

    $.ajax({
        url: 'http://search.twitter.com/search.json?q=' + encodeURIComponent(q),
        dataType: 'jsonp',
        timeout: 5000 /* 5 seconds timeout, plenty of time for the request to complete */
    })
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Just trying to figure out if this has been solved or not. I have
I have this line of code and am trying to figure out the pros
Really struggling to figure this out. Just trying to take in data from php
I'm getting really tired of trying to figure out why this code works in
Hello I'm just trying to figure out the concept of this example menu http://www.cdrking.com
I am just trying to figure out how to work this out. So, I
I've been trying to figure this out and I am hopelessly stuck. I have
Right I have given in, after about 2 hours trying to figure out this
I'm just trying to figure out why I can't do this: <?php $a =
Lost a bunch of time just trying to figure out what was going on

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.