Jump to content


Photo

Getting a return success message or returning the data after submitting form

success page return data

Best Answer rad1964, 11 September 2013 - 12:07 PM

I get the javascript data being written to my initial form page (at the bottom) so it is reading the fields properly, The AJAX, does not yet play a part, please ignore that.

 

In my form tag I have an action="process.php" - what is not happening is the successful.html does not show up, which is called at the bottom of my process.php, which makes me think that the process.php is not being read...

 

Newbie here, in case you couldn't tell.

thanks,

 

rad1964

Go to the full post


  • Please log in to reply
4 replies to this topic

#1 rad1964

rad1964

    Member

  • Members
  • PipPip
  • 15 posts
  • LocationSan Francisco, CA
  • Age:48

Posted 10 September 2013 - 01:54 PM

Hello,

I want to test that the data that is submitted through a form is being captured. And or a succes message is sent.

Attached is the form code (grh.html), javascript (grh.js), form processing (process.php), success page (success.html).

 

Basically I am using AJAX to return the form fields that were filled out. When that didn't work, I added the success page which is also not working.

 

Any ideas?

 

 

Here is my js file contents since the uploader will not upload a .js file....

 

//AJAX - Creates the XMLHttpRequest that sends a http request to the web server
function getXMLHTTP() {
    var x = false;
    try {
        x = new XMLHttpRequest();
    }
    catch(e) {
        try {
            x = new ActiveXObject("Microsoft.XMLHTTP");
        }
        catch(ex) {
            try {
                req = new ActiveXObject("Msxml2.XMLHTTP");
            }
            catch(e1) {
                x = false;
            }
        }
    }
    return x;
}

//Retrieves the Forms field values *This is a TEST for diagnostic purposes*
function displayFormValues()
{
    var str = '';
    var elem = document.getElementById('formGrh').elements;
    for(var i = 0; i < elem.length; i++)
    {
        str += "<b>Name: </b>" + elem[i].name + "&nbsp;&nbsp;";
        str += "<b>Value: </b>" + elem[i].value + "&nbsp;&nbsp;";
        str += "<br />";
    }
    document.getElementById('lblValues').innerHTML = str;
}

 

TIA,

rad1964

 

 

Attached Files



#2 gristoi

gristoi

    Advanced Member

  • Members
  • PipPipPip
  • 799 posts

Posted 10 September 2013 - 03:36 PM

 it is 2013, not 1993. Use Jquery ajax to make your ajax call. 

 

$.ajax({

  url: 'yourphpscripturl.php',

  data: $('#yourform').serialize(),

  success: function(data){

alert(data.response)

}

});


To err is human... to really foul up requires the root password

#3 rad1964

rad1964

    Member

  • Members
  • PipPip
  • 15 posts
  • LocationSan Francisco, CA
  • Age:48

Posted 10 September 2013 - 05:21 PM

Making that change does not make anything work, thanks for the 2013 version, but 1993 was a good year :)



#4 rad1964

rad1964

    Member

  • Members
  • PipPip
  • 15 posts
  • LocationSan Francisco, CA
  • Age:48

Posted 11 September 2013 - 12:07 PM   Best Answer

I get the javascript data being written to my initial form page (at the bottom) so it is reading the fields properly, The AJAX, does not yet play a part, please ignore that.

 

In my form tag I have an action="process.php" - what is not happening is the successful.html does not show up, which is called at the bottom of my process.php, which makes me think that the process.php is not being read...

 

Newbie here, in case you couldn't tell.

thanks,

 

rad1964



#5 rad1964

rad1964

    Member

  • Members
  • PipPip
  • 15 posts
  • LocationSan Francisco, CA
  • Age:48

Posted 13 September 2013 - 05:35 PM

Solved, the submit button had generic button insted of submit.






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

Cheap Linux VPS from $5
SSD Storage, 30 day Guarantee
1 TB of BW, 100% Network Uptime

AlphaBit.com