Jmal West Jmal West - 3 months ago 12
HTML Question

How to change specific element on ajax ?

I have ajax call that change the user info. And I want to get the value from the response and change value of specific element
Example: the element that need to chage:

<div id="changeMe"><!-- New Value --> </div>


Ajax call:

$.ajax({
url: "?rr=profile",
}).success(function(response) {

});


How to change the value of the "changeMe" element ONLY ?

Answer

Try it with

$.ajax({
    url: "?rr=profile",
}).success(function(response) {
var r = $( response ).find( "#changeMe" );
    $( "#changeMe" ).html( r.html() );  
});