Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Regular Coder
    Join Date
    Jun 2006
    Location
    UK
    Posts
    922
    Thanks
    302
    Thanked 3 Times in 3 Posts

    Question jquery form submission help

    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.
    Code:
    	<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>
    load.php page script
    PHP Code:
    <?php
    echo $_GET['tname'];
    ?>
    However, the above does not work.


    Can you help me plz?


    Thanx

  • #2
    Senior Coder shyam's Avatar
    Join Date
    Jul 2005
    Posts
    1,563
    Thanks
    2
    Thanked 163 Times in 160 Posts
    Quote Originally Posted by cancer10 View Post
    Code:
    	<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>
    you are sending the request twice and not sending the value for the request that mattters...

    try

    Code:
    $("#quote").load("load.php", { tname: "John", ttime: "2pm" });
    You never have to change anything you got up in the middle of the night to write. -- Saul Bellow


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •