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 6944107
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T13:14:35+00:00 2026-05-27T13:14:35+00:00

i work with page using prototype, and i have to add some ajax requests,

  • 0

i work with page using prototype, and i have to add some ajax requests, which updates content of one specified div.
Here how i did it in jquery:

$j.ajax({
    url: url,
    success: function (result) {
        var resultDiv = $j(result).find('.SOME-CLASS');
        $j('.SOME-CLASS').html(resultDiv.html());
    }
});

I tried to get the same result with prototype for last few hours and finaly i gave up. How would it look in prototype ? Its important to withdraw from result div with class SOME-CLASS and replace its content with existing in document div with the same class.

PS.
I thought about parsing raw result string recived from prototypes request to get content of and then replace founded content with existing in document, but in my opinion this is bad, non elegant solution. Is there anything better ? I heard that prototype is great tool for DOM manipulation.

  • 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-27T13:14:36+00:00Added an answer on May 27, 2026 at 1:14 pm
    new Ajax.Request(url, {
        onSuccess: function(response) {
            var html = new Element('div');
            html.update(response.responseText);
            // There may be many .SOME-CLASS so use `invoke` to iterate through them
            $$('.SOME-CLASS').invoke('update', html.select('.SOME-CLASS').first());
        }
    });
    

    Prototype doesn’t have an equivalent to jQuery’s $(htmlString) shortcut, so you’ll have to assign the HTML string to a newly created element then extract the child classes back (which is how jQuery does it behind the scenes). The temporary element is never added to the DOM so isn’t seen directly.

    When searching for the incoming element by it’s class we must use Element.select which returns an array. If we assume there will be only one match, or are only interested in one match, the first element of that array is used. Perhaps this isn’t what you wanted and meant to collect multiple elements from the response. That is an ambiguity caused by using class names instead of IDs.

    Here is a demonstration fiddle.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a page which opens another page using window.open and does some work
I have a page which work like a navigation and a iframe in this
I have a page which does quite a bit of work and I don't
I need to add a CSS style to a content <div> , which is
Like many variables in PHP using ini_set() on a page doesn't actually work. I've
Page in question: http://phwsinc.com/our-work/one-rincon-hill.asp In IE6-8, when you click the left-most thumbnail in the
I add html to a page using JQuery's html() function. This works great on
I recently came across a web page using the font ff-tisa-web-pro-1 (specified in their
which way to reload a current page (using a button) would you prefer? 1
I have a Facebook like button on my page using the XBFML tag. I

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.