Html update page without refresh




















I have a website where I need to update a status. Like for a flight, you are departing, cruise or landed. I want to be able to refresh the status without having my viewers to have and reload the whole page.

I also don't want them to have and click a button. If anybody knows how that would be done I much appreciate it! This is typically achieved with a technique called AJAX. This technique loads data asynchronously in the background so it can update your content without needing to reload the page. This method provides a simple way to load data asynchronous from a web server and place the returned HTML into the selected element.

The optional data parameter allows you to specify data i. The optional complete parameter can be used to reference a callback function. The callback is fired once for each selected element. A simple example of using load , where we load data dynamically when a button is pressed:. If you don't want to use the jQuery library, you can also use plain Javascript. Loading content is slightly more difficult that way. Here is an example of how to do it with javascript only.

Suppose you want to display some live feed content say livefeed. In the below html file , the live data gets updated on the div element of id "liveData". Below autoUpdate. I have given comments on most part of the code for better understanding.

For testing purpose: Just write some thing in the livefeed. Above function will call after every 10 seconds and get content from response. If you want to know how ajax works, it is not a good way to use jQuery directly. Thanks Arun.

Posted Oct am vivektiwari Add your solution here. OK Paste as. Treat my content as plain text, not as HTML. Existing Members Sign in to your account. This email is in use. Do you need your password? Submit your solution! When answering a question please: Read the question carefully. Understand that English isn't everyone's first language so be lenient of bad spelling and grammar.

If a question is poorly phrased then either ask for clarification, ignore it, or edit the question and fix the problem. Insults are not welcome. Don't tell someone to read the manual. Chances are they have and don't get it.

Provide an answer or move on to the next question. Let's work to help developers, not make them feel stupid. Related Questions. Refresh datatable without refreshing page. Learn more. Update data on a page without refreshing Ask Question. Asked 7 years, 9 months ago. Active yesterday. Viewed k times. MattGotJava 2 2 silver badges 13 13 bronze badges. Gidimotje Gidimotje 1 1 gold badge 4 4 silver badges 9 9 bronze badges.

Hi and welcome to SO. It does not work like elancer. Add a comment. Active Oldest Votes. Jean-Paul Jean-Paul Thanks for the advice! But in your exemple I need to click a button as well, is there a way that the data is updated without any clicking?

You can also use a simple setTimeout statement to load the content after x seconds. In the below html file , the live data gets updated on the div element of id "liveData" index.

SridharKritha SridharKritha 6, 2 2 gold badges 36 36 silver badges 35 35 bronze badges. Below code may be help you just example.

Thomas Orlita 1, 13 13 silver badges 26 26 bronze badges. Butani Vijay Butani Vijay 3, 2 2 gold badges 26 26 silver badges 56 56 bronze badges. This link may be help you more : 9lessons. Shin Shin 7 7 bronze badges.



0コメント

  • 1000 / 1000