I wrote a script and I want to change the language. I managed to do this using the .ajax() function in jQuery and fetching the new HTML.
Afterwards I want to replace the old HTML with the new HTML.
However, I do not want to exchange the whole HTML, but only part of it.
I know that the HTML returned includes a <div id="myDivId">...</div>, so I only want to get the content of that div from the HTML returned, and replace the content of my current div with the new content.
But, I can’t seem to figure out how to fetch only that content from my new HTML. How can I do that? I tried using find, but no success.
$.ajax({
type: "GET",
url: "ajax.php",
data: "action=languagepack&subAction=box&newIso="+newIso+"&country="+country,
success: function(htmlCode){
var box = $(htmlCode).find('#myDivId').html();
alert(box);
}
});
Best regards,
Paul Peelen
Try jQuery.load()
Loading Page Fragments