javascript - How can i tell PHP which form is submitted -


is there way tell php form has been submitted?

form 1

<form id="factory" action="bullets.php" method="post">     <input type="submit" value="kopen"> </form> 

and form 2

<form id="localfactory" action="bullets.php" method="post">     <input type="submit" value="kopen"> </form> 

these forms on 1 page.

my javascript code:

    var url;      $('form').submit(function (event) {         event.preventdefault();          url = $(this).attr('action');          location.hash = url;          $.ajax ({             url: url,             method: 'post',             data: $(this).serialize()         }).done(function (html) {             $('#content').html(html);         });     }); 

if got input $_post variable.

so need know of above forms has been submitted?

thanks..

this work:

var url;  $('form').submit(function (event) {     event.preventdefault();      url = $(this).attr('action');      location.hash = url;     var data = $(this).serialize();     data += "&formid=" + encodeuricomponent($(this).attr('id')); // if have data in form.     // if don`t have data in form:     // data = {formid: $(this).attr('id')};      $.ajax ({         url: url,         method: 'post',         data: data     }).done(function (html) {         $('#content').html(html);     }); }); 

you can forms id $_post['formid']


Comments

Popular posts from this blog

c++ - No viable overloaded operator for references a map -

java - Custom OutputStreamAppender not run: LOGBACK: No context given for <MYAPPENDER> -

java - Cannot secure connection using TLS -