Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/445.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
Javascript 如何在ajax上获得另一个页面?_Javascript_Php_Jquery_Ajax - Fatal编程技术网

Javascript 如何在ajax上获得另一个页面?

Javascript 如何在ajax上获得另一个页面?,javascript,php,jquery,ajax,Javascript,Php,Jquery,Ajax,我的页面第一个代码有问题(假设是hompe.php) 在我的ajax控制器上,我喜欢这些(我使用的是FrameworkLaravel) 在我的ajax/跟踪视图上,如下所示 <?php //$json = array(); $json = "<input type='text'></input>"; echo json_encode($json); ?> 在ajax/tracking/kp(视图)中,我将这些代码 <input

我的页面第一个代码有问题(假设是hompe.php)

在我的ajax控制器上,我喜欢这些(我使用的是FrameworkLaravel)

在我的ajax/跟踪视图上,如下所示

<?php
    //$json = array();
    $json = "<input type='text'></input>";
    echo json_encode($json);
?>
在ajax/tracking/kp(视图)中,我将这些代码

<input type='text'></input>


并且正在工作。

问题在于:

success: function(html) {
    // Problem : $(html).find('#trackingkp').html(); 
    $('#trackingkp').html($(html).find('#trackingkp').html());
}
html
响应将从中返回
json
值 在给定的[控制器]中

<?php
    //$json = array();
    $json = "<input type='text'></input>";
    echo json_encode($json);
?>

希望这对您的情况有所帮助

当您尝试将
替换为
'
变量时会发生什么?@eeya:语法错误,无法识别的表达式:“”。嗯,请仔细检查:
echo json_encode(“”
)。它仍然返回[syntax]错误吗?@eeya:nope结果仍然是相同的语法错误,无法识别的表达式:“我想尝试获取像require\u这样的内容一次,但使用jquery和ajax。因为我需要get Parameter表和字段。well有点正常,但仍然显示syntact error Unrecogned expression:“”或Syntax error,Unrecogned expression:“”当您使用console[html]时,您得到了什么响应
console.log(html)
syntact error unrecognized expression:“”或Syntax error,unrecognized expression:“”仍然相同,但nvr注意,我发现使用naother选项,您可以查看我的更新问题,tq获取您的答案:)注意到。干得好
 Syntax error, unrecognized expression: "<input type='text'>
public function index(){

    is_header(); 
    $this->view('home',[]);
    $this->view('ajax/tracking/kp',[]); ---> I add these
    is_footer(); 
}
<input type='text'></input>
success: function(html) {
    // Problem : $(html).find('#trackingkp').html(); 
    $('#trackingkp').html($(html).find('#trackingkp').html());
}
<?php
    //$json = array();
    $json = "<input type='text'></input>";
    echo json_encode($json);
?>
$("<input type='text'></input>").find('#trackingkp').html();  
$.ajax({
    type: "POST",
    url: host+"ajax/tracking/kp",
    dataType: 'json', // Kindly replace [html] to [json] since you are returning a [json] value
    success: function(html) {
        $('#trackingkp').html(html);        
    }
});