Skip to content Skip to sidebar Skip to footer

Handling CloneNode On The Server

I need that when I click on the 'add' button a certain div should be cloned. To achieve this I am using the following code : - function addDetails() { var details=document.

Solution 1:

You cannot see the newly created DIVs beaceuse browser view-source function renders the original HTML file that was downloaded from the server (before any JavaScript has taken an effect). If you want to see the real HTML as you see it in the browser, use the DomElement innerHTML property, or some DOM inspector (Firebug for Firefox, DragonFly in opera, F12 in internet explorer).
What you should do is to send an AJAX request to the server with the information that some new data were created and have the server generate the new HTML. This should happen independently on the client addDetails function.
On the client side, you also should remove the new DIV if the AJAX call fails.

Because you didn't state how the page is generated, I can give you no leads how should the PHP script handle the AJAX requests. This is up to you unless you provide us with more details.


Post a Comment for "Handling CloneNode On The Server"