本文介绍了ajax没有返回响应以查看应用程序中的页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当我在firefox控制台窗口中调试时,我可以看到输出,但是它不在我的viewpage中,下面我提到了我的ajax代码和控制器,我得到了结果,但是视图未显示
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'm 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>
控制器:
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));
}
}
推荐答案
应该
$('#property').empty('clear').html(row.html);
不是
$('#property').empty('clear').html(data.html);
.sucess()也拼写错误.应该是.success()
Also .sucess() is spelt wrong. It should be .success()
这篇关于ajax没有返回响应以查看应用程序中的页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!