Over a million developers have joined DZone.

When Creating Dynamic Content With AJAX Don't Forget To...

·
When using AJAX to get data from the server to fill an HTML element, some peolpe find that the AJAX call only works the first time it is executed. If your request returns different data each time there is nothing to worry about but if the server returns the same data twice, nothing will happen on the page the second time. To prevent a null AJAX call you need to clear the HTML element (e.g. 
) that is displaying the data before executing the request.

Data returned from the server

Topics:

The best of DZone straight to your inbox.

SEE AN EXAMPLE
Please provide a valid email address.

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.
Subscribe

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}