javascript - jQuery form submission fail -


good afternoon everybody.

i have got quick question ask why jquery not submitting form data.

this form:

 <form id="submitform" action="" method="">                 <input class="ui-input-text ui-body-null ui-corner-all ui-shadow-inset ui-body-c" type="text" name="from" placeholder="your email" style="color:#ccc;" />                 <input class="ui-input-text ui-body-null ui-corner-all ui-shadow-inset ui-body-c" type="text" name="fullname" placeholder="your full name" style="color:#ccc;"  />                 <input class="ui-input-text ui-body-null ui-corner-all ui-shadow-inset ui-body-c" type="text" name="contactnumber" placeholder="your contact number" style="color:#ccc;"  />                 <input class="ui-input-text ui-body-null ui-corner-all ui-shadow-inset ui-body-c" type="text" name="subject" placeholder="subject" style="color:#ccc;"  />                 <textarea placeholder="your message here..." class="ui-input-text ui-body-null ui-corner-all ui-shadow-inset ui-body-c" name="body" style="color:#ccc;" ></textarea>                  <input type="submit" id="search_button" value="submit!" name="submit" />              </form> 

here jquery code:

 <script type="text/javascript">         $(document).ready(function(){              $('#loading, .loading-text').hide();              $('form#submitform').submit(function( event ){                  event.preventdefault();                  document.write('hola!');                  $('#loading').show();                 var formdata = $('form#submitform').serialize();                 $.ajax({                     url: 'majax.php',                     data: formdata,                     type: "get",                     success: function( data ){                         $('#loading, .loading-text').show();                          if( !data.error ){                             $('.alerttext').html(data).show();                         } else {                             $('.alerttext').html(data + data).show();                         }                         $('#loading, .loading-text').hide();                     }                 });                 return false;             });         });     </script> 

i know may vague question, have been trying while , can't think of else try.

the problem i'm having when click submit or submit form, nothing happens, doens't reach document.write('hola!'); bit , definatly doesn't reach ajax call.

any on try appreciated.

thanks in advance!

i think because didn't provide method , action.
instead of:

<form id="submitform" action="" method=""> 

do:

<form id="submitform" action="[your current file]" method="get"> 

Comments

Popular posts from this blog

objective c - Change font of selected text in UITextView -

php - Accessing POST data in Facebook cavas app -

c# - Getting control value when switching a view as part of a multiview -