DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: AJAX on click function not working more than once.

  1. #1
    Join Date
    Apr 2007

    AJAX on click function not working more than once.

    I have an onclick that needs to repeat the function as many times as the user may decide to click. However, for some reason no matter what, if they click it once its only going to return the desired effect once, at which point they'd need to re open the page and click it again.

    Since I don't want to post the whole server side process, I have an example..

    Here's "TCG.PHP", the page the AJAX communicates with.

    <?PHP echo rand(0,255); ?>
    Everytime they click a certain button, it calls the AJAX which calls that page. However, more than one click won't work. Say I push the button, it will return say (39?), and if i click again it just keeps 39 rather than redoing the server side process.

    And ofcourse, the AJAX

    function user(input){
    	var ajaxRequest;
    		ajaxRequest = new XMLHttpRequest();
    	} catch (e){
    			ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
    		} catch (e) {
    				ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
    			} catch (e){
    				alert("Your browser broke!");
    				return false;
    	ajaxRequest.onreadystatechange = function(){
    		if(ajaxRequest.readyState == 4){
    			   var ajaxDisplay = document.getElementById('u1');
    			   ajaxDisplay.innerHTML = ajaxRequest.responseText;
    	   var queryString = "?user=" + input;"GET", "tcg.php" + queryString, true);
    And also, the button in which they click:

    <input type='button' onclick='user("blabla")' />
    Does anyone know what the issue is? >_>

    note: works fine on FF, but not on IE7.

    I dont exactly want to shut out my IE7 users though.. so if anyone can help thatd be nice

  2. #2
    Join Date
    Apr 2007

    Cool URL Caching

    Try to append a date time variable with the URL like

    this way every time the url would be different and hence not cached.


Similar Threads

  1. Getting a GUI to run
    By Eric in forum Java
    Replies: 4
    Last Post: 04-14-2006, 09:09 AM
  2. Getting a GUI to function
    By Eric in forum Java
    Replies: 1
    Last Post: 11-27-2001, 07:53 AM
  3. AnimateWindow API
    By Tim Manos in forum VB Classic
    Replies: 4
    Last Post: 10-19-2001, 06:06 AM
  4. Replies: 2
    Last Post: 08-07-2000, 11:48 AM
  5. Please help me -- urgent -- deadlock error
    By chandra in forum VB Classic
    Replies: 0
    Last Post: 06-22-2000, 07:36 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
Latest Articles
Questions? Contact us.
Web Development
Latest Tips
Open Source

   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center