bonaca bonaca - 1 year ago 100
PHP Question

How to avoid URL $_GET variables after submitting a form with ajax?

<form id='gbookform'>
<input id='inputname' type='text' name='name' autocomplete='off' placeholder='Your name'>
<input id='inputcon' type='text' name='contact' autocomplete='off' placeholder='Your contact or website'>
<div id='forminfo'></div>
<textarea id='inputstory' name='story' rows='9' placeholder='Your story'></textarea>
<div class="g-recaptcha" data-sitekey="6LfobygTAAAAACxBzCl1FxPe4lALE-669wt6NC7G"></div>
<input id='btnsubmit' type='submit' value='SEND'>


$("#gbookform").submit(function(e) {
type: "POST",
url: "gbookajax.php",
data: $(this).serialize(),
success: function(data) {

After submitting the form I see my variables written inside url:


How can I avoid this ?

Answer Source

Just specify the form method :

<form id='gbookform' method='post'>...</form>
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download