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.

Member Avatar for GreenDay2001

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.

Member Avatar for diafol

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" />	
</form>

Here's the progressive enhancement:

$(document).ready(function() {
$("frmlogin").submit(function(e) {
  e.preventDefault();
  //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).

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.