Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/389.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变量在javascript上传递多个参数_Php_Javascript_Variables_Parameters - Fatal编程技术网

使用php变量在javascript上传递多个参数

使用php变量在javascript上传递多个参数,php,javascript,variables,parameters,Php,Javascript,Variables,Parameters,我有以下javascript,它将php站点重新加载到div中: if (boxes.length) { $(".loadingItems").fadeIn(300); // Change the name here as well $(".indexMain").load('indexMain.php?'+this.name+'=' + boxes.join("+"), function() {

我有以下javascript,它将php站点重新加载到div中:

if (boxes.length) {
          $(".loadingItems").fadeIn(300);
            // Change the name here as well
            $(".indexMain").load('indexMain.php?'+this.name+'=' + boxes.join("+"),
            function() {
                $(".indexMain").fadeIn('slow');
                $(".loadingItems").fadeOut(300);
            });
我想在同一url中传递另一个参数

所以我想我应该按照下面的方法来做,尽管我不能让它工作。这条路对吗

我试图使用php变量
$category
传递参数
categ
,如下所示:

 if (boxes.length) {
        $(".loadingItems").fadeIn(300);
        // Change the name here as well
        $(".indexMain").load('indexMain.php?categ=<?php echo $category;?>&'+this.name+'=' + boxes.join("+"),
        function() {
            $(".indexMain").fadeIn('slow');
            $(".loadingItems").fadeOut(300);
        });
if(box.length){
$(“.loadingItems”).fadeIn(300);
//在这里也更改名称
$(“.indexMain”).load('indexMain.php?categ=&'+this.name+'='+box.join(“+”),
函数(){
$(“.indexMain”).fadeIn('slow');
美元(“.loadingItems”)。淡出(300);
});

我可以看出这不起作用的两个潜在原因(代码似乎很好…):

  • php不会被执行;javascript位于外部
    .js
    文件中,或者html文件的扩展名是
    .html
    而不是
    .php
  • 您回显的变量包含无效字符。应使用以确保不会发生这种情况:

  • 看起来不错。请显示渲染的输出好吗