SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Enthusiast
    Join Date
    Aug 2006
    Posts
    27
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    AJAX will not refresh page with same input value

    Hi, ive got a simple text box which will successfully echo out some code when its submitted using AJAX, if I change the contents on the input it will refresh again, but if i click the submit button with the same value in the input it will not refresh properly.

    This is probably very simple so has anyone an idea why this isnt working?

    The code i got (off these forums) is below.

    PHP Code:
    var http;

    function 
    createRequestObject() {

       var 
    req;

       if(
    window.XMLHttpRequest){
          
    // Firefox, Safari, Opera...
          
    req = new XMLHttpRequest();
       } else if(
    window.ActiveXObject) {
          
    // Internet Explorer 5+
          
    req = new ActiveXObject("Microsoft.XMLHTTP");
       } else {
          
    // There is an error creating the object,
          // just as an old browser is being used.
          
    alert('Problem creating the XMLHttpRequest object');
       }

       return 
    req;

    }



    function 
    sendRequestGET(act) {
        
        
    // Make the XMLHttpRequest object
        
    http createRequestObject();
        
       
    // Open PHP script for requests
       
    http.open('get''myphpscript.php?act='+act);
       
    http.onreadystatechange handleResponse;
       
    http.send(null);

    }

    function 
    sendRequestPOST(v1v2v3v4v5) {

        
    // Make the XMLHttpRequest object
        
    http createRequestObject();

       
    // Open PHP script for requests
       //http.abort;
       
    http.open('post''ajaximage.php');
       
    http.onreadystatechange handleResponse;
       
    http.setRequestHeader('Content-Type''application/x-www-form-urlencoded'); 
       
    http.send('v1=' v1 '&v2='v2 '&v3='v3 '&v4='v4 '&v5='v5);

    }

    function 
    handleResponse() {

        if (
    http.readyState != 4) {
            return;
        }
        
        
    // Text returned FROM the PHP script
        
    var response http.responseText;

        
    document.getElementById("ajaxResponse").innerHTML response;



  2. #2
    SitePoint Enthusiast
    Join Date
    Aug 2006
    Posts
    27
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    After examining the HTTP headers, the submit button is submitting the data again but nothing's coming back when the value is the same..


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •