0

A have a page with 6 (Jquery) tabs and on each tab there is a form, i want to submit one of the forms without refreshing the whole page. When i submit a form i want to "reload" the same form in that tab, but with the $_POST data so i can use that for PHP scripting (database insert after vallidation).

I tried Jquery AJAX, but i have to define al the form ellement again to pass the POST data, is'nt there a way similar like action="" but then only for that one tab and not the whole page?

Jilco Tigchelaar
  • 2,065
  • 8
  • 31
  • 51

1 Answers1

1
$('form').submit(function(e){ 
    e.preventDefault(); //to prevent the page form reloading

    //provide the ajax call part after this

    return false; // to exit the function without actually submitting the form
});
mccbala
  • 183
  • 1
  • 7
  • You don't need both, to return false in jQuery is the same as preventDefault and stopPropagation. – adeneo Dec 16 '12 at 17:14
  • I returned a boolean since it is unwise to write a function that returns no value, unless you're absolutely sure that you don't need one here. This return value could be used in other decision making processes. – mccbala Dec 16 '12 at 17:20
  • 1
    No it can't, and no you should'nt. There's no need to return a value in an event handler like that. You're thinking of regular functions that will return undefined unless a return value is specifically given. – adeneo Dec 16 '12 at 17:23
  • So if I don't specify a return value, what would it be for the function I write for this event handler? – mccbala Dec 16 '12 at 17:32
  • 1
    It would be `this`, as it's a chainable jQuery method. – adeneo Dec 16 '12 at 18:31