javascript - Replace part of the page with jQuery -


I wrote a script and I want to change the language. I am able to get it in jQuery by using the .jax () function and bringing new HTML. Later, I want to replace the old HTML with the new HTML.

However, I do not want to exchange full HTML, but only a part of it I know that in HTML a and

, so I only want to get the contents of that div from HTML, and replace the contents of my existing divas with new content. But, I can not seem to know how can I get to do just this stuff from my HTML? I tried to find, but did not get success. $ Ajax ({type: "GET", url: "ajax.php", data: "Action = levelpak & sub-action = box & newISO =" + new "+ and country =" + country, success: Function (htmlCode) {var box = $ (htmlCode). Find ('# myDivId') .HTML (); Alert (box);}});

/ P>

This is the easiest way to get data from server to server. (URL, data, success), except that it is a method rather than a global function and has an implicit callback function. When a successful response is received (i.e. when textstats are "success" or "nodified"), .load () sets the HTML content of the matched elements of the data being loaded, which means that most of the method usage is quite simple Can:

  $ ('# result'). Load ('ajax / test.html');   

Loading parts of the page

.load () method, unlike $ .get (), we Allows to specify one that has been obtained with a special syntax for the url parameter to insert part of the remote document. If one or more locations are included in the character string, then the first part of the string is considered a jQuery selector which determines the content to load.

We can modify the example given above Use only one part of the received document:

  $ ('#select'). Load ('ajax / test.html #container');    

Comments