php - How to Manipulate JQuery .get() response -


using suggestion found @ http://richardmiller.co.uk/2011/03/04/jquery-manipulating-ajax-response-before-inserting-into-the-dom/ able manipulate data response jquery .get() method, i'm unable make changes object.

javascript

$.get( "returnajax", function( data ) {     var $data = $(data);     $data.find('#testdiv').append('<p>some text</p>');     console.log($data); }); 

php

public function returnajax() {     return "<div id='testdiv'></div>";  } 

the output in console <div id="testdiv"></div>

this seems simple thing i'm not doing right...

see .find()

get descendants of each element in current set of matched elements, filtered selector, jquery object, or element.

which traverses $data descendants #testdiv , $data appear #testdiv element ?

try

$data.append('<p>some text</p>');console.log($data.is("#testdiv"))


Comments

Popular posts from this blog

PHP DOM loadHTML() method unusual warning -

python - How to create jsonb index using GIN on SQLAlchemy? -

c# - TransactionScope not rolling back although no complete() is called -