Jump to content
rizwansyed

Back button issue

Recommended Posts

Hi

Whenever i click on submit button,It goes to other page in html and i need to press back button.

I came to know that with AJAX, It is possible to avoid going to next page as it does in background.

Can anyone please share a example for ajax submit form

Please suggest

 

Thanks and Regards

Rizwan Syed

Share this post


Link to post
Share on other sites

It's a lot easier if you just post your code in a code box here on the forum.

In general, you need too attach an event handler to whatever event you want to use, in this case the form's submit event, and your event handler should cancel the default event action and do its own thing instead.  So, you create your XHR object, set the URL, method, etc, set your ready state change handler, get your data to submit and send it.  You handle any server response in the ready state change handler.

Share this post


Link to post
Share on other sites

Hi 

As you suggested i am able to submit the form with POST and url.am able to receive it on server side.

But not getting any data.

Submit is success but no data.I think submit is not getting any data.so it is submitting with no data.

Attached is my modified source code.

Please suggest how to get a data in submit 

Thanks and Regards

Rizwan Syed

mass.txt

Edited by rizwansyed

Share this post


Link to post
Share on other sites

I think submit is not getting any data.so it is submitting with no data.

You should verify that then.  Print out the data you're trying to submit to the console.

Your code doesn't show you getting any of the form data.  You need to get the data in Javascript that you want to send, and send it to the server.  It does not gather all of the form data, how is Javascript supposed to know what data you want to send?  You need to pass the data in a formatted string to the XHR object's send method.

Again, please copy and paste your code into a code box in the forum instead of attaching a file.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...