Ajax PHP代码无法正常工作

My script should bring up data in the textboxes when the Id number is entered in the ID textbox. The issue is that the information relating to the ID number comes up but only when i put in the ID number and reload the page not when the value is entered and the other information just automatically appear.

here is the script

         <script language="javascript" type="text/javascript">

jQuery(document).ready(function()
{

$("#tid").keyup(function()
{
    var value = $(this).val();
    $.ajax({
        url: "index.php",
        type: 'POST',
        data: {itemNo: $("#tid").val() },
        success: function(data)
        {
            var obj = jQuery.parseJSON(data);
            $("#tname").val(obj.name);
            $("#tprice").val(obj.price);

        }
    });
});
});
</script>


 <?php
        $client = new nusoap_client("http://localhost:1234/cwork/webfunction.php#");
        $ans = $client->call('ArraySearch', array("inum" => $stf));
        echo "<br>";
        $vars = explode(",", $ans);
        ?>

 <label> Item# : </label> <input type="text" class="tid" name="txtid" value="<?php if (count($vars) > 1) echo htmlspecialchars($stf); ?> " /> <br> <br>


             <label>  Name :</label> <input type="text" name="txtname" class="tname" size="25" value="<?php if (count($vars) > 1) echo htmlspecialchars($vars[1]); ?>" /> <br> <br>


             <label>  Price :</label> <input type="text" name="txtprice" class="tprice" value="<?php if (count($vars) > 1) echo htmlspecialchars($vars[2]); ?>"  /><br> <br>


             <label>  Quantity:</label> <input type="text" name="txtqty" /> <br> <br>

                <input type="hidden" name="formsubmitted" value="TRUE" />
                <input type="submit" class = "submit" value="Add to cart" onclick="myfnc()"/> 

In your AJAX call, you have

$("#tname").val(obj.name);
$("#tprice").val(obj.price);

But in your HTML tags, you have them as classes.

It should be

$(".tname").text(obj.name);
$(".tprice").text(obj.price);

'#' are used for ids