开发者

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

开发者 https://www.devze.com 2022-12-18 11:00 出处:网络
I want to pass both the values using ajaxForm, displaying both the values separately in test.php -------test.php-----------------------------------------

I want to pass both the values using ajaxForm, displaying both the values separately in test.php

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

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

$('#test_form').ajaxForm({
    targ开发者_StackOverflow社区et:'#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";

?>

Thanks Jean


Hy Jean

Welcome to Stackoverflow

Here is the fixed code:

-------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 :-)
?>
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号