how to submit form using jquery mobile?

How to I change the action attribute for a html form on submit with JQuery using the jquery form plugin?

  • I am using the following plugin here: jquery.malsup.com/form/ I want to make it so that when the user clicks Submit, it changes the attribute action like: $('$theform').get(0).setAttribute('action', 'theurliwant'); My issue is, I do not know where to put that because the JQuery Form Plugin appears to have its own handlers, and when i stick a click handler on the submit button, it seems to catch the event without going to JQuery Form Plugin's handlers. Where can I stick the code to change the action?

  • Answer:

    Take a look at the http://jquery.malsup.com/form/#options-object for your plugin. The answer is there. Under options url: URL to which the form data will be submitted. Default value: value of form's action attribute There is also beforeSubmit Callback function to be invoked before the form is submitted. The 'beforeSubmit' callback can be provided as a hook for running pre-submit logic or for validating the form data. If the 'beforeSubmit' callback returns false then the form will not be submitted. The 'beforeSubmit' callback is invoked with three arguments: the form data in array format, the jQuery object for the form, and the Options Object passed into ajaxForm/ajaxSubmit. beforeSubmit: function(arr, $form, options)

Damascusi at Stack Overflow Visit the source

Was this solution helpful to you?

Other answers

Have you tried putting it in here (looking at the API you linked) // attach handler to form's submit event $('#myFormId').submit(function() { // submit the form $(this).ajaxSubmit(); // return false to prevent normal browser submit and page navigation return false; }); though I'm not sure how exactly you are using the, some more code might help out.

RodH257

Related Q & A:

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.