Hi, I want to load a fragment of external html document (external.html#embeddedContent) with the help of AJAX call, embed (inject) this into my HTML document (main.html#placeToInject), and change this embedded fragment a little.
I think that I need load this external fragment and either 1) change this before injection, or 2) inject and change at once before user will notice anything. The both possibilities are ok for me now, but I have a problem with manipulating and filtering the embedded fragment while working with jquery 1.2.1. If I follow the second (2) way, I need to do any manipulation only when content has been already injected into the code. But the following code doesn’t work. Means $(“..”) below relates to original fragment in main.html that has been presented there before injection. See comments in the code. $(document).ready(function(){ // load and inject content var content = "main.html"; $("#placeToInject").load(content + " #embeddedContent > *"); // change the loaded fragment // here $(“..”) relates to original fragment in main.html (before injection). $("#placeToInject > .price").addClass("bold"); }); If I follow the first (1) way, I need to have the access to just loaded document (DOM). So I need to attach these manipulation actions to the event that show that the ajax call has been successfully completed. I have tried to do the POST instead GET (since I don’t know how to use the load function with GET and attached function). But I can’t filtering the classes (element with given class) in the fragment. See the comment in the code. $(document).ready(function(){ // load content var embeded = "embedded.html"; $("#placeToInject").load(embeded + " #embeddedContent > *", null, function(){ // it doesn’t want to match the classes (means elements with class=”price”) that are located into the loaded fragment $(this).filter(".price").addClass("bold"); }); }); I think that it possible to try function .ajaxSuccess( function(evt, request, settings){ alert($(this).filter("#left-side").html()); }); But I don’t know how to prepare the rest of the parameters for my needs, right now. Please provide me feedback, if I properly use the functions above and how may I fix that problems. Thanks