Help me find a bug. This somehow does not work, i.e. does not submit the form.

<html> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8" /> <script type="text/javascript" src=""></script> <script type="text/javascript" src=""></script> </head> <body> <script type="text/javascript"> $(document).ready(function(){ var string =$("#form1").formSerialize(); $("#click").click(function(){ $.load("md5.php",string,function(data){ alert("Data Loaded: " + data); }); $("#1").hide(); $("#1").show(1000); }); }); </script> <div id='1'> </div> <form id ="form1"> <input type="text" name="a"> <input type="submit" id="click" value="test"> </form> </body> </html> 
  • And what is the general problem? Just submit the form? - ling

2 answers 2

First, what do you load with the $ .load () method?
Secondly, specify the form method, do not force the browser to read the tea leaves that you want from it, i.e. here:

 <form method="post" action=""> <input type="text" name="a"> <input type="submit" id="click" value="test"> </form> 

And third: giving digital aydices to the blocks (id = '1') is a bad tone, if at all permissible (I’m not sure here).

And it’s fun for you that by clicking on the form submit you should be sending it and in parallel with it - uploading. Question: what is this fraud? ;)

  • Should send and download the response from the server - Egor Bay
  • Well, then you need to send a form on Ajax! Use not the $ .load () function, and ideally $ .ajax (), well, or its simplified version $ .post ()! - metazet

And you have this page with the form can handle what you send? If the form has no action parameter, then POST and GET requests are sent to the page from which the data was sent.