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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T17:49:33+00:00 2026-05-24T17:49:33+00:00

Here is what I have so far: $(function () { dataValModify(‘body’); $(‘body’).bind(‘ajaxSuccess’, function (e,

  • 0

Here is what I have so far:

$(function () {
    dataValModify('body');

    $('body').bind('ajaxSuccess', function (e, xhr, settings) {
        dataValModify(xhr.responseText);
    });
});

function dataValModify(elem) {
    // Code to modify elements within the response.
}

How can I take the Ajax response and modify it before it is injected into the DOM? Previously, I was binding ajaxComplete and modifying the DOM directly after injection, but I would like to modify the response instead. I don’t think it makes a lot of sense to find elements in the Ajax response and use them to modify the DOM. I send the xhr.responseText into my function so that I don’t reapply the modifications to the rest of the body, which will have already been modified by the time of an Ajax call. Also, is there something better than xhr.responseText to use for this? I couldn’t get xhr.responseHTML to work.

EDIT: Right now I’m just using a simple test Ajax call to return an MVC partial view:

$('#ajaxTest').load('<MVC Route>')
  • 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-24T17:49:34+00:00Added an answer on May 24, 2026 at 5:49 pm

    If I’m understanding your requirements correctly, they are as follows:

    • Make an asynchronous HTTP request to get some HTML
    • Modify the returned HTML using the dataValModify() function
    • Insert the modified HTML into your element with the ID: ‘ajaxTest’

    If so then it sounds to me like you need to make a lower level ajax call than what you’re using at present i.e. $(elem).load()

    Essentially the call to .load() is a wrapper for $.get() followed by a call to $(elem).html(someContent) where “someContent” is the responseText from the HTTP request.

    Therefore if you want to modify the response before it’s injected into the DOM, then you can do something similar to the following:

    $.ajax({
      type: "GET",
      url: "<MVC Route>",
      dataType: "html", 
      success: function(jqXHR, textStatus, errorThrown){
    
        // Your HTTP call was successful but nothing else has happened with the response yet
        // Therefore you can now do whatever you want with the it...
    
        // First modify the HTML using the dataValModify function
        // Assumption being that your function returns the modified HTML string
        var myModifiedHTML = dataValModify(jqXHR.responseText);
    
        // Inject the modified HTML
        $('#ajaxTest').html(myModifiedHTML);
      }
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm a total newb to LINQ. Here is the code I have so far:
Here's what i have so far: function loadOff(){ $(document).ready(function(){ $(#eLoader).ajaxStop(function(){ $(this).hide(); $(#eventsContent).show(); var h
Here is what I have tried thus far: > cd /Applications/MAMP/bin/php5/bin/ > ./pear channel-discover
I really wonder why this question hasn't popped up here so far. I have
enter code here I have a table on SQL server 2005 with bigint primary
Ok here's what I have so far.. thanks to Paolo. And it works fine,
Here's what I have so far but thing aren't really working. (I dragged the
Just wondering what little scripts/programs people here have written that helps one with his
Since upgrading to 2008 I and many people here have noticed that randomly VS
Here I have: Public Structure MyStruct Public Name as String Public Content as String

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.