Its a small test.php file and basically what it does is refreshes the div tag when the button is clicked without refreshing the whole page.
and not sure why its not working on IE(8 & 10)
Basically what happens is that it loads the random number at initial load which is fine but if i click the button to generate a new random number it does nothing.
reason for using php random number generator, is for testing purposes. later i will put in a php script that does something else . this script is to just get the javascript to working more specifically my objectives is to figure out a way to refresh a DIV tag without refreshing the whole page.
It looks like it’s Internet Explorer that you’re having that problem with. What happens with it, is when an identical request goes to the server, the client doesn’t send that but gives you a cached response instead, from when the same request was sent earlier.
So, you either need to make a request for different information, or to prevent the cached response from occurring.
Which one you choose depends on the situation. Normally you don’t want to make duplicate requests for the same identical information, because that results in more hard work for your server.
jQuery’s .ajax() method gives you the power to prevent the cached response from occurring.
Thanks for your help, I greatly appreciate helping me with this script.
your fix fixed the problem with IE.
My skills are pretty weak when it comes to ajax and i was wondering if you can help me with one more question…
I have a class called “questions.php” and a method called public function displayQuestions(). how can i use the script you provided to return the results from the method. once the results are returned I was going to use if statement (php)to display the results in a table format.
public function displayQuestions()
{ return $this->questionArray; }
Then you can reference it from within the success callback.
Just remember to echo whatever you want your PHP script to return to your JavaScript and set the datatype accordingly, then all will be well.
Also, if things are not behaving as expected, use the console to debug.