簡體   English   中英

使用jQuery和PHP為ajaxForm()傳遞兩個值

[英]Passing two values for ajaxForm(), using jQuery and PHP

我想使用ajaxForm傳遞兩個值,在test.php中分別顯示兩個值

-------test.php-----------------------------------------

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

$('#test_form').ajaxForm({
    target:'#result',

    success:function() {
        $('#result').show();
    }
});


</script>



<form id="test_form" method="" action="test1.php">
<input type="submit" id="sub" value="sub_value">
</form>

<div id="result"></div>

-------test1.php---------------------------------------


<?
$t="test value";
$u="test value 1";

?>

謝謝讓

海蘭吉恩

歡迎來到Stackoverflow

這是固定代碼:

-------test.php-----------------------------------------

<script language="javascript" type="text/javascript">
$.post("test.php", {testval: val}, function(data){
   if (data.length>0){ 
 $('#result').show();
     $("#result").html(data); 
   } 
  }) 


</script>



<form id="test_form" method="" action="test1.php">
<input type="submit" id="sub" value="sub_value" name="testval">
</form>

<div id="result"></div>

-------test1.php---------------------------------------


<?
// now coding in PHP is easiyer
if(isset($POST["testval"]))
{
// this is now for your Learning purposes that you see how things are 
$testval = strip_tags(mysql_escape_string($POST["testval"]));
echo $testval;
}
// thats it have fun :-)
?>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM