0

This is my html code

 <td class="saltr" style=" border-color:#000; cursor:pointer;" id="<?php echo $grade["DEALID"];?>" onclick="dealid(this.id)" ><?php echo $grade["DEALINGS"];?></td>

on onclick() javascrip is written.

function dealid(psid)
{
    var serow = psid;
    //alert (serow)
    $.ajax({url:"../views/printdeal.php?proc=dealing",data:"dealdatres="+serow,success:
    function(z)
            { 
              //alert("hiiiii")
                alert(z);
                //window.location="printdeal.php";
            }
        });

}

and in printdeal.php page the code is written as

if($_REQUEST["proc"]=='dealing')
    {   

     $dealdatres1=$_REQUEST["dealdatres"];
    include_once("../classes/dbqrs.php");
    $obj=new qrys();
    $qremp="select deals.PROSPECS ,deals.DEALINGS,deals.BUYER,deals.BENEFICIARY,deals.GUIDE,deals.REMARKS ,deals.DATES,salescal.DEALID from salescal left join deals on deals.ID=salescal.DEALID where salescal.DEALID='$dealdatres1'";

$empr=$obj->exeqry($qremp);
$empres=mysqli_fetch_array($empr);
?>

but when I run this code and when i click on it ,it shows a notice as undifined "proc" .

Please help me to solve this.

4

4 回答 4

0

It looks like you have placed you function somewhere out of usual global scope. I don't know what should be changed as far as I cannot know your structure.

At first, move all function's content into onclick:

onclick='$.ajax({url:"../views/printdeal.php?proc=dealing",data:"dealdatres="+this.id,success:
    function(z)
            { 
              //alert("hiiiii")
                alert(z);
                //window.location="printdeal.php";
            }
        });'

and get a proof that there is something wrong with the name/placement only.

P.S. BTW read about addEventListener/attachEvent as strong and more convenient alternative to "onclick" usage.

于 2013-10-25T06:53:36.643 回答
0

We have kinds of ways to get the function,one of them like this:

You may write the code in view page :

 $.ajax({
                url: "<?php echo url('/soc/cnews/savetop') ?>",
                type: 'post',
                data: "sets=" + $("#top10").val(),
                sync: false,
                dataType: 'json',
                success: function(data) {
                    if (data.status == 'success') {
                        window.location.reload();
                    } else {
                        alert(data.msg);
                    }
                }
            });

and the write the code in page which get data:

if($success){
                        echo "{status:'success',msg:'victory'}";
                    }else{
                        echo "{status:'failur',msg:'I am sorry to failure :('}";
                    }

And again: if you want get data via ajax,make sure print or echo the message on data page.

于 2013-10-25T06:54:32.160 回答
0

Try This

$.ajax({type: "POST",url: "../views/printdeal.php",data: { proc:"dealing",dealdatres=serow }});

于 2013-10-25T06:57:46.010 回答
0

if your problem in php, i think you can check values in global variables with

<pre>
  <?php
  var_dump($_REQUEST);
  ?>
</pre>

the result can be like this

array(2) {
  ["asd"]=>
  string(3) "qwe"
  ["zxcv"]=>
  string(5) "lkjsf"
}

that's result is from my localhost with url localhost/a.php?asd=qwe&zxcv=lkjsf

于 2013-10-25T07:07:55.373 回答