Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/37.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 Jquery Ajax url变量检索不正确_Php_Javascript_Mysql_Ajax - Fatal编程技术网

Php Jquery Ajax url变量检索不正确

Php Jquery Ajax url变量检索不正确,php,javascript,mysql,ajax,Php,Javascript,Mysql,Ajax,我从一个文件到另一个文件有这个ajax请求,我在另一个文件中检索url变量,如下所示 $.ajax({ dataType : "html" , url: "jquery-loadMoreComments.php?lastComment="+ $(".postedComment:last").attr('id')&"section="+'.$sid.', success: function(html) { 第一个变量被正确地检索,但第二个变量没有到达另一个文件。第一个文件从

我从一个文件到另一个文件有这个ajax请求,我在另一个文件中检索url变量,如下所示

    $.ajax({
dataType : "html" ,
url: "jquery-loadMoreComments.php?lastComment="+ $(".postedComment:last").attr('id')&"section="+'.$sid.',   
success: function(html) {
第一个变量被正确地检索,但第二个变量没有到达另一个文件。第一个文件从url中检索
$sid
,然后通过ajax发送到第二个文件以继续请求

我把url改成了这个

$filtered = filter_input(INPUT_GET, "lastComment", FILTER_SANITIZE_URL);
$filtered1 = filter_input(INPUT_GET, "section", FILTER_SANITIZE_URL);

但它仍然没有执行。我认为
$sid
变量传递不正确。在第一个php文件中,我没有编写任何代码来传递variabl
$sid
,我如何才能做到这一点。

我怀疑问题在于URL末尾的
'.$sid'
。您可能希望用PHP变量替换它,但这看起来不像是替换发生的上下文

要进行替换,您需要返回到PHP处理模式,例如

$filtered = filter_input(INPUT_GET, "section", FILTER_SANITIZE_URL);

你能解释一下吗?我认为ajax调用中存在一些问题帮你自己一个忙,在ajax调用之前声明你的查询字符串参数,这会使你的ajaxurl参数更干净,更容易读取,因为url字符串是无效的。检查您的连接。@rahulrawat:“我想”--您可以继续猜测或使用
var\u dump($\u GET)$sid
是什么数据类型。如果它是一个数字,你不需要在它周围加引号(虽然它们不会有什么坏处,因为它们在URL中会以相同的方式结束)。我如何将值从php文件传递到javascript文件?这就是
所做的。它是
的缩写。你在混淆范例。如果不在
数据:
参数中,则不能使用
部分:'
$filtered = filter_input(INPUT_GET, "section", FILTER_SANITIZE_URL);
"&section=<?= $sid ?>",
$.ajax({
    dataType : "html" ,
    url: "jquery-loadMoreComments.php",
    data: {
        lastComment: $(".postedComment:last").attr("id"),
        section: '<?= $sid ?>'
    },
    success: function(html) {