I have form that getting values from query string and I have a form. On submission I have to show messages into the same page and I have two FORMs.

Is there any possibility using AJAX, if yes then How ? I have two FORMs.

6 Years
Discussion Span
Last Post by diafol

Yes. If you know AJAX, you wont have much problem. You just have to make a GET or POST request and handle the response. Post the code if you get stuck somewhere.


Using jQuery to handle the ajax (post or get) will probably allow you to fix a solution in about 4 lines of js (jquery).

However, keep js as progressive enhancement. Ensure that your form will work even when js is disabled, e.g.

Take a typical login form:

<form name="frmlogin" id="frmlogin" action="includes/login.php" method="post">
  <label for="u">User:</label>
  <input id="u" name="u" type="email" placeholder="(your email)" />
  <label for="p">Password:</label>
  <input id="p" name="p" type="password" />
  <input id="slogin" name="slogin" type="submit" value="Login" />	

Here's the progressive enhancement:

$(document).ready(function() {
$("frmlogin").submit(function(e) {
  //do your ajax stuff here
  return false;

The form will still be sent if no js. jQuery is set to 'hijack' the submit form event so it can run an in-page login. The js-less version will take the user to the login page and then most likely redirect back to the calling page (or whichever page you choose).

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.