Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/290.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/72.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/solr/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 将参数传递给函数POST_Php_Jquery - Fatal编程技术网

Php 将参数传递给函数POST

Php 将参数传递给函数POST,php,jquery,Php,Jquery,我在JQuery中有两个函数,第一个函数将把地址ip发送到脚本php indexFunctions.php。这个地址将被第二个函数JQuery使用。我已经成功地通过.get获得地址ipval。现在我想用$rpi=“http://”将这个@ip传递给函数$\u POST;但当我像这样设置$rpi=”时,它不起作用http://192.168.1.15“它起作用了,我得到了这个错误 Undefined variable: ip in /var/www/html/web/indexFunctions.

我在JQuery中有两个函数,第一个函数将把地址ip发送到脚本php indexFunctions.php。这个地址将被第二个函数JQuery使用。我已经成功地通过
.get
获得地址ipval。现在我想用$rpi=“http://”将这个@ip传递给函数
$\u POST
;但当我像这样设置$rpi=”时,它不起作用http://192.168.1.15“它起作用了,我得到了这个错误

Undefined variable: ip in /var/www/html/web/indexFunctions.php on line 36,
请帮忙。多谢各位

脚本indexFunctions.PHP:

   if (isset($_GET['ipval']))
 {
    $ip=$_GET['ipval'];
  }
  $rpi="http://".$ip;
  if (isset($_POST['stbInfo']))
  {  

  if($_POST['stbInfo']=="On")
  {

   $url=$rpi.'/StbGetDataModel.php';}
脚本index.PHP:

jQuery(document).ready(function(a) {
    setip(ip);
    stbStatus(stbInfo);
});

var ip = "192.168.1.15";

function setip(a) {
    $.get("indexFunctions.php", {
        ipval: a
    }, function(a) {
        $("#results").html(a);
        console.log(a);
    }, "html");
}

function stbStatus(a) {
    $.post("indexFunctions.php", {
        stbInfo: a
    }, function(a) {
        $("#StbInfo").html(a.text);
    }, "json");
}
var ip=“192.168.1.15”

变量Ip必须首先声明才能使用
setip(Ip)所以你的代码看起来像

var ip = "192.168.1.15";//moved first
jQuery(document).ready(function(a) {
    setip(ip);
    stbStatus(stbInfo);
});

function setip(a) {
    $.get("indexFunctions.php", {
        ipval: a
    }, function(a) {
        $("#results").html(a);
        console.log(a);
    }, "html");
}

function stbStatus(a) {
    $.post("indexFunctions.php", {
        stbInfo: a
    }, function(a) {
        $("#StbInfo").html(a.text);
    }, "json");
}
PHP代码:

$ip     =   isset( $_GET["ipval"] ) ?   $_GET["ipval"]  : "127.0.1.1";
$rpi    =   "http://".$ip;
$url    =   ( isset( $_POST['stbInfo'] ) && $_POST['stbInfo'] == "On" ) ?   $rpi.'/StbGetDataModel.php' : $rpi.'/StbGetDataModel.php' ;
var ip=“192.168.1.15”

变量Ip必须首先声明才能使用
setip(Ip)所以你的代码看起来像

var ip = "192.168.1.15";//moved first
jQuery(document).ready(function(a) {
    setip(ip);
    stbStatus(stbInfo);
});

function setip(a) {
    $.get("indexFunctions.php", {
        ipval: a
    }, function(a) {
        $("#results").html(a);
        console.log(a);
    }, "html");
}

function stbStatus(a) {
    $.post("indexFunctions.php", {
        stbInfo: a
    }, function(a) {
        $("#StbInfo").html(a.text);
    }, "json");
}
PHP代码:

$ip     =   isset( $_GET["ipval"] ) ?   $_GET["ipval"]  : "127.0.1.1";
$rpi    =   "http://".$ip;
$url    =   ( isset( $_POST['stbInfo'] ) && $_POST['stbInfo'] == "On" ) ?   $rpi.'/StbGetDataModel.php' : $rpi.'/StbGetDataModel.php' ;
如果Isset为FALSE,他仍然尝试在第4行中使用$ip


如果Isset为FALSE,他仍然尝试在第4行中使用$ip

这些函数中的参数来自何处<代码>设置ip(ip)
stbStatus(stbInfo)@Chay22 stbInfo=”“Rpistatus=“on”和@ip=192.168.1.15您可以将这两种语言混合为一种语言,而无需将其分离。我只是内心困惑。如果在调用
setip()
函数之前定义var
ip
会怎么样。不,我没有混合使用这两种语言,我有一个名为index.php的脚本,其中包含函数jquery,我还有一个脚本indexFunctions.php if(isset($\u GET['ipval']))…@chay22我得到这个错误“未定义的变量:第36行的/var/www/html/web/indexFunctions.php中的ip,referer:”这些函数中的参数来自哪里<代码>设置ip(ip)
stbStatus(stbInfo)@Chay22 stbInfo=”“Rpistatus=“on”和@ip=192.168.1.15您可以将这两种语言混合为一种语言,而无需将其分离。我只是内心困惑。如果在调用
setip()
函数之前定义var
ip
会怎么样。不,我没有混合使用这两种语言,我有一个名为index.php的脚本,其中包含函数jquery,我还有一个脚本indexFunctions.php if(isset($\u GET['ipval'))…@chay22我得到了这个错误“未定义的变量:第36行/var/www/html/web/indexFunctions.php中的ip,请参考:“您好,感谢您在我使用echo显示$rpi时给出的答案您好,感谢您在我使用echo显示$rpi时给出的答案@hemnath mouli Fri May 20 10:45:33.487367 2016][:error][pid 3347][client 127.0.0.1:33089]PHP注意:未定义变量:ip在/var/www/html/web/indexFunctions.PHP第37行,referer:@Ktarizied我已经更新了PHP,你现在可以试试吗?我试过了,但它对@127.0.1.1不起作用,当我输入地址192.168.1.15时,它起作用了,但我搜索传递了地址,比如参数not fixed@hemnath mouli Fri May 20 10:45:33.487367 2016][:error][pid 3347][client 127.0.0.1:33089]PHP注意:未定义变量:ip in/var/www/html/web/indexFunctions.PHP在第37行,referer:@Ktarizied我已经更新了PHP,你现在可以试试吗?我试过了,但在我输入地址192.168.1.15时,它不适用于@127.0.1.1。它可以工作,但我搜索传递地址,就像参数not fixed一样