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

  • Home
  • SEARCH
  • 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 6156283
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T20:34:58+00:00 2026-05-23T20:34:58+00:00

I have an Ajax call written in prototype and need to convert it to

  • 0

I have an Ajax call written in prototype and need to convert it to jquery. I’m not well versed in requestHeaders and the like, so I’m a bit stumped. Here’s the prototype version:

function poll_for_update(feed_id, last_modified, link) {
  setTimeout(function() {
    new Ajax.Request('/feeds/' + feed_id, {
      method: 'get',
      requestHeaders: { 'If-Modified-Since': last_modified },
      onComplete: function(transport) {
        if (transport.status == 304) {
          poll_for_update(feed_id, last_modified, link);
        } else if (transport.status == 200) {
          $('feed_' + feed_id).innerHTML = transport.responseText
        } else {
          link.innerHTML = 'error'
        }
      }
    }) },
    1000
  )
}

Since I can extract the feed_id and last_modified dates from the link, my early version of the corresponding jquery functions looks like this:

function poll_for_update(link) {
    var feed_id = $(link).attr('feed_id')
    var last_modified = $(link).attr('last_modified')
    setTimeout(function() {
        $.ajax({
            url: show_path(link),
            type: 'get',
            ifModified: true,
            headers: { 'If-Modified-Since': last_modified },
            statusCode: {
                404: function() {
                    alert('404');
                },
                304: function() {
                    alert('304');
                },
                200: function() {
                    alert('200');
                }
            },
            success: function( data ) {
                alert('success');
            },
            complete: function() {
                alert('complete');
            }});
    }, 1000)
}

A few things I can’t figure out:

  • how do I extract transport.status from within the complete() function?
  • do I need the statusCode: clause, or is the complete: clause sufficient?
  • is the ifModified clause necessary?

… etc.

(For the curious, this is a transcription of Adam Wiggins’s tutorial on how to build a queue-backed feed reader, which is super useful but somewhat outdated.)

TIA.

  • 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-05-23T20:34:59+00:00Added an answer on May 23, 2026 at 8:34 pm

    Here’s what I ended up with, and it appears to work. What wasn’t obvious to me was that the ‘transport’ object is passed as an argument to the completion() method. Once I realized that, the jquery implementation is quite close to the prototype version:

    function poll_for_update(link) {
        var feed_id = $(link).attr('feed_id')
        var last_modified = $(link).attr('last_modified')
        setTimeout(function() {
            $.ajax({
                url: show_path(link),
                type: 'get',
                headers: { 'If-Modified-Since': last_modified },
                complete: function( transport ) {
                    if (transport.status == 304) {
                        poll_for_update(link)
                    } else if (transport.status == 200) {
                        $('#feed_' + feed_id).html(transport.responseText)
                    } else {
                        $(link).html('error ' + transport.status)
                    }
                }
            });
        }, 1000)
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a jQuery AJAX call with type:'GET' like this: $.ajax({type:'GET',url:'/createUser',data:userId=12345&userName=test, success:function(data){ alert('successful'); }
I am running ASP.NET MVC Beta. I have an AJAX call running through jQuery
A situation I ran across this week: we have a jQuery Ajax call that
I have a generic ajax Error handler written like so: $('html').ajaxError(function(e, xhr, settings, exception)
I have written jQuery code, in files Main.html and ajax.php . The ajax.php file
Where does the jquery ajax success callback return to? I have written a request
i have an ajax call $.ajax({ url: '<%=Url.Action(SaveDetails,Survey) %>', dataType: 'JSON', cache: false, data:
I have an AJAX call getting info out of the Github API. It is
I have an ajax call that fires multiple times but is called once. function
I have an ajax call. I put the return value (data) in a variable

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.