user2734398 user2734398 - 2 years ago 72
jQuery Question

Jquery form in the same page

My question is about forms with jQuery, usually the pages uses forms with jQuery need call other page for send the form or verificate the same without reload the page.

My question: is it possible to use jQuery with forms in the same page and no need call other for works fine?

For example if I have this simple form in php and html:


<div id="request">
if ($_REQUEST[ 'send']=="ok" ) {
if ($_REQUEST[ 'username']=="" ) {
print "bad field";
} else {
print "Form send ok";


<form id="forma" name="form" method="post" action="?">
<input type="text" name="username" id="textfield" />
<input type="submit" name="button" id="button" value="Send Message" />
<input type="hidden" name="send" id="ok">

How I can send this form from this same page and no call other or external page with jQuery, it´s possible process all inside the same page and use jquery for no reload ?

I don´t know many about jQuery with forms by this if it´s possible put code for after this create more things

Thanks for the help

Answer Source

yes there you can use ajax (asynchronous javascript) to do that like

  type: "POST",
  url: "some.php",
  data: { name: "John", location: "Boston" }
}).done(function( msg ) {
  alert( "Data Saved: " + msg );

see documentation to use as you like.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download