[PHP & MySQL] Update Website Data Dynamically?
Go to solution
Solved by burnttoastnice,
Adding to his answer, jQuery (a Javascript library) has an Ajax function which is pretty straightforward as well as the code being much shorter and much neater compared to the original Javascript function.
Below is a simple modified jQuery ajax example I got from sitepoint:
$.ajax({ url: 'http://google.com', success: function(data) { //See Note#1 alert(data); }, error: function() { //see Note#2 alert("Whoops, Error"); }});
Note#1: If the request is a success, the function would be called with 'data' holding the entire response of the webpage. For Google (the request in the example) it would return all the code on that page.
Note #2: If there is an error, it will carry out this function. There are extra variables that can be put into either function to catch various elements of the HTTP response, such as the code (e.g. 404 not found, or 403 forbidden)
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now