Sample URL:
Note: Please use the test sign in credentials: test/test for username/password.
I am currently working on an AJAX request to fetch data from a database. The serverTime.php file appears to be functioning correctly as it is inserting and returning the expected responseText.
However, I have noticed that the request is being triggered twice. This was evident when debugging with Firebug. As a result, the page seems to 'reset' in some way, causing my cursor to lose focus from the current textbox. Additionally, even if my message is not empty, the URL shows "localhost/twitter/index.php?message=". I would like to resolve this minor issue before it escalates into a major problem.
Below is the JavaScript code. ajaxRequest represents my XMLHTTPRequest object. Any assistance would be greatly appreciated!
// Function to handle data received from the server
ajaxRequest.onreadystatechange = function(){
if (ajaxRequest.readyState == 4){
document.getElementById('output').innerHTML = ajaxRequest.responseText;
}
}
// Build query string
var message = document.myForm.message.value;
var queryString = "message=" + message;
// Send AJAX request
ajaxRequest.open("GET", "serverTime.php" + "?" + queryString, true);
ajaxRequest.send(null);
Thank you,
Paragon