Hi, I am trying to run a simple jQuery script that would load a php page "load.php" on click of a submit button and the load.php page would return the value of "tname" variable which is "John" in this case. Following is my jQuery script. <script src="jquery-1.2.6.js"></script> <script> $(document).ready(function(){ $("form#myform").submit(function() { $.get("load.php", { tname: "John", ttime: "2pm" }); $("#quote").load("load.php"); return false; }); }); </script> <div id="quote"></div> <form method="post" id="myform"> <input name="submit" type="submit" value="Submit" /> </form> Code (markup): load.php page script <?php echo $_GET['tname']; ?> PHP: However, the above does not work. Can you help me plz? Thanx
Well, it works. It does exactly what you scripted it to do. If you want to simply "GET load.php" file while passing something to it, just do it with normal JavaScript. window.location="load.php?tname=John&ttime=2pm"; Code (markup): <script src="jquery-1.2.6.js"></script> <script> $(document).ready(function(){ $("form#myform").submit(function(){ window.location="load.php?tname=John&ttime=2pm";return false; });}); </script> <div id="quote"></div> <form method="post" id="myform"> <input name="submit" type="submit" value="Submit" /> </form> Code (markup):
Question: Can I have 2 Submit buttons in a form one for adding and the other for deleting? Well, I wanna do the addition and deletion in jQuery. How do I implement the condition statement in jQuery that if submit button is add then do the add function and if the submit button is delete then do the delete function? Thanx