Menuear.com

Inspiring the world.

Updating your web page without refreshing the page

When someone visits your website, they are actually viewing your web page on their local computer.

The page may have been created on the fly on your hosting server using PHP and MySQL and then downloaded to the user’s computer, but when the visitor views the page, it’s on their local computer.

The Javascript code on the page can also make the web page more dynamic, but the user’s browser handles the Javascript dynamics.

Since the user is viewing your web page on their local computer, any updates that need to be made to the page that require PHP and/or MySQL must be done at the server level. This means that something on the page, such as a button or link, must send another request to the server to get updated information. This used to require a page refresh.

Clicking a link or button would send the message to the server that another server page was needed. It could have been the same page with new and updated information, but as far as the server was concerned, it was a new page.

In other words, once the page has been created and sent to the user’s local computer, the only way to interact with the server is to send another request. This used to mean that the user’s browser would send the request and receive a new response to display a new page.

With advances in technology, advances in the languages ​​we now use for web development, and advances in our web browsers, it is now possible to refresh specific sections of a page without refreshing the entire page. This has allowed web developers to create web ‘applications’ instead of just web ‘pages’. Web applications look and behave more like applications that you would run on your local computer. This new technology is called Ajax – Asynchronous Javascript and XML.

The Javascript within the web page can be activated to send a message, asynchronously. According to Wikipedia, in programming, asynchronous events are those that occur independently of the main flow of the program. In this case, these events send messages to the server while the viewer is still viewing and/or interacting with the web page. It is all happening behind the scenes and the user may not even be aware that it is happening.

The XML part of the Ajax name is the format in which messages are usually sent. XML stands for Extensible Markup Language. It is similar to HTML and is widely used on the Internet to send messages from one computer to another, just like HTML.

The biggest difference between XML and HTML is that HTML is basically a limited set of XML. HTML is designed for one type of application, browsers, while XML can be used for most applications. It’s basically just a standard way of sending messages electronically.

XML is very popular and works very well because, in addition to having HTML-like tags, it also allows you to define your own tags. This means you can send almost any type of information, and since you can define your own labels, you can make it pretty clear what the data actually means.

Since Ajax still sends a message over the Internet, the response is not real-time and can be quite slow in some cases, but it is much faster and much more convenient than waiting for the entire page to refresh.

Not only that, but it allows forms and pages to change based on user input or mouse movements on the page. We do not have to wait until the entire form is filled out before sending some of the information. This allows the entire form to change before it is completely filled.

For example, let’s say I have a form about cars. In that form I have a radio button for 2 doors or 4 doors. Depending on which one the user selects, I want to give them a drop down list of the 2 or 4 door cars I have available for them to select from the list. Before Ajax, I had to have combinations available on my form that weren’t actually available. Only after the user had submitted their form could my scripts check if the combination they chose was available or not. So my script would return an error message.

With Ajax, I can query my database while the user is still filling out the form and reply to them within the form before they click the submit button. This reduces the number of errors the user will have to experience before successfully completing the form.

This is just one example of the many wonderful things that Ajax can help us incorporate into our web applications. It’s making the Internet much more dynamic and much more interactive. Ajax is a web developer’s dream!

Related Posts

Leave a Reply

Your email address will not be published. Required fields are marked *