ajax is not returning respones to view page in the application

人盡茶涼 提交于 2019-12-11 23:27:39

问题


when I am debugging in firefox console window i can see the output but it's not coming on my viewpage , below i have mentioned my ajax code and my controller, i getting a result but view is not showing

Ajax:

      <script>
$('.click').click(function(evt) {
 evt.preventDefault();
 var link = $(this).attr('id');
$.ajax({
   type: "GET",
   url: 'p_details',
   dataType: "json",

   data: {
      id: link   
 }


});
   //alert(data);
}).done(function(data) { // pass the url back to the client after you    incremented it
$('#property').empty('clear').html(data.html);
});
 </script>

controller:

    public function index()
            {
         //$filter=Input::get('id');
       //var_dump($term);
        $view=DB::table('property_details')
     ->Where('sale_or_rent', '=', 'rent')
        ->orWhere('sale_or_rent', '=', 'sale')
       ->get();
     //  var_dump($view);
    return view::make('index', array('val'=>$view));
}

    public function getPropertyDetails()
      {
         $filter = Input::get('id');
        $display = DB::table('property_details')
                  ->where('sale_or_rent', 'LIKE', '%' . $filter . '%')
                  ->get();
                  //var_dump($display); 

                 if(count($display)!=0)
                    {    
                      $returnHTML = view('/pages/fliter')->with('val', $display)->render();
                      return response()->json(array('success' => true, 'html'=>$returnHTML));
                    }
                    else
                    {
                    session::flash('status', 'No Records Found!!!');
                    $returnHTML = view('/pages/fliter')->with('val', $display)->render();
                    return response()->json(array('success' => true, 'html'=>$returnHTML));
                    } 
      } 

回答1:


Should

$('#property').empty('clear').html(row.html);

not be

$('#property').empty('clear').html(data.html);

Also .sucess() is spelt wrong. It should be .success()



来源:https://stackoverflow.com/questions/35917039/ajax-is-not-returning-respones-to-view-page-in-the-application

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!