Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/251.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 将视图数据从控制器传递到Ajax视图文件-Laravel 5_Php_Laravel 5 - Fatal编程技术网

Php 将视图数据从控制器传递到Ajax视图文件-Laravel 5

Php 将视图数据从控制器传递到Ajax视图文件-Laravel 5,php,laravel-5,Php,Laravel 5,在查看页面中,我将Ajax调用到我的控制器,在控制器中,我希望创建一个html数据,因此我将数组传递到查看文件以创建html数据。 我不知道为什么当我试着去做的时候什么都没有得到回报,有人能告诉我哪里出了问题吗 从视图文件调用JAXFROMVIEWFILE function AjaxgetCheckInChekOutUser(status){ var url = "{{ url('admin/events/ajaxData') }}"; var token =

在查看页面中,我将Ajax调用到我的控制器,在控制器中,我希望创建一个html数据,因此我将数组传递到查看文件以创建html数据。 我不知道为什么当我试着去做的时候什么都没有得到回报,有人能告诉我哪里出了问题吗

从视图文件调用JAXFROMVIEWFILE

function AjaxgetCheckInChekOutUser(status){
    var url = "{{ url('admin/events/ajaxData') }}";
    var token = $('#token').val();
    if(status){
        $.ajax({
                headers: {
                'X-CSRF-Token': $('meta[name="csrf-token"]').attr('content')
                },
                url: url,
                type: 'POST',
                data: {'status': status,'_token':token},            
                success: function (data) {
                    alert(data);
                    data = JSON.parse(data);      
                        console.log(data.html);
                        $('#gymimages').html(data.html);
                    
                }
        });
    }
}
public function AjaxCurrentPastFutureData($data, $status){
    $title = "HDTuto.com";  

    $html = view('admin.events.ajaxdataview')->with(compact('title'))->render();
    //pr($html);
    $response = response()->json(['success' => true, 'html' => $html]);
    return $response;
}
myControllerFile

function AjaxgetCheckInChekOutUser(status){
    var url = "{{ url('admin/events/ajaxData') }}";
    var token = $('#token').val();
    if(status){
        $.ajax({
                headers: {
                'X-CSRF-Token': $('meta[name="csrf-token"]').attr('content')
                },
                url: url,
                type: 'POST',
                data: {'status': status,'_token':token},            
                success: function (data) {
                    alert(data);
                    data = JSON.parse(data);      
                        console.log(data.html);
                        $('#gymimages').html(data.html);
                    
                }
        });
    }
}
public function AjaxCurrentPastFutureData($data, $status){
    $title = "HDTuto.com";  

    $html = view('admin.events.ajaxdataview')->with(compact('title'))->render();
    //pr($html);
    $response = response()->json(['success' => true, 'html' => $html]);
    return $response;
}
NowmyViewFile从中添加HTML数据

<h1><i>{{ $title }} </i></h1>
{{$title}
谁能告诉我哪里出了问题吗?

**用这个**

function AjaxgetCheckInChekOutUser(status){
var url = "{{ url('admin/events/ajaxData') }}";
var token = $('#token').val();
if(status){
    $.ajax({                
            url: url,
            type: 'POST',
            data: {'status': status,'_token':token},            
            success: function (data) {                    
                    $('#gymimages').html(data.html);
            }
    });
同时更新控制器功能

public function AjaxCurrentPastFutureData(Request $request){
    $title = "HDTuto.com";  
    $html = view('my')->with(compact('title'))->render();
    //pr($html);
    $response = response()->json(['success' => true, 'html' => $html]);
    return $response;
}**使用此**

function AjaxgetCheckInChekOutUser(status){
var url = "{{ url('admin/events/ajaxData') }}";
var token = $('#token').val();
if(status){
    $.ajax({                
            url: url,
            type: 'POST',
            data: {'status': status,'_token':token},            
            success: function (data) {                    
                    $('#gymimages').html(data.html);
            }
    });
同时更新控制器功能

public function AjaxCurrentPastFutureData(Request $request){
    $title = "HDTuto.com";  
    $html = view('my')->with(compact('title'))->render();
    //pr($html);
    $response = response()->json(['success' => true, 'html' => $html]);
    return $response;

}

您的请求中有什么内容?签入您的网络XHR请求。这样,当我在公共关系($data)时,你就会知道你在传递什么,得到什么样的回应;这是印刷bt唯一的东西是不返回你的要求是什么?签入您的网络XHR请求。这样,当我在公共关系($data)时,你就会知道你在传递什么,得到什么样的回应;它正在打印bt唯一的东西是不返回谢谢你这解决了我的问题我先做错了,然后按照你的代码做,一切正常谢谢你这么多你救了我一天谢谢你这解决了我的问题我先做错了,然后按照你的代码做,一切正常谢谢你这么多你救了我一天我的日子