我在下拉列表中有四个选项,我正在尝试根据选择的选项从数据库中过滤数据,我已经检查过控制台数据即将到来,但在我的视图页面数据并不令人耳目一新,我已经附上请检查一下,我正在努力帮助。
这是我的HTML代码视图
right_side_bar latest image
check this image for html view reference
<select id="property_id" name="property_type" onchange="property_type(this.value)">
<option>Property Type</option>
<option value="Single Family Home">Single Family Home</option>
<option value="Multi_Family_Home">Multi Family Home</option>
<option value="Condominium">Condominium</option>
<option value="Townhome">Townhome</option>
</select>
这是我的右侧代码
@if (session('status'))
<div class="alert alert-danger">
{{ session('status') }}
</div>
@endif
@foreach($row as $val)
<div class="property-box">
<div class="property-box-inner">
<div class="property-box-picture">
<div class="property-box-price">
<a href="#">{{$val->state}}</a></div>
<div>
<a href="#" class="property-box-picture-target">
<img src="../images/test/{{$val->image}}" />
</a>
</div>
</div>
<div class="property-box-meta" id='basic-modal'>
<div class="property-box-meta-item col-xs-3 col-sm-3">
<strong>{{$val->property_room}}</strong>
<span>Bedroom</span>
</div>
<div class="property-box-meta-item col-xs-3 col-sm-3">
<strong>{{$val->property_baths}}</strong>
<span>Bath</span>
</div>
<div class="property-box-meta-item col-xs-3 col-sm-3">
<strong>{{$val->property_size}}</strong>
<span>Area</span>
</div>
<div class="property-box-meta-item col-xs-3 col-sm-3">
<strong>{{$val->property_baths}}</strong>
<span>Garages</span>
</div>
<a href="{{ URL::to('pages/property_details', array('id'=>$val->id)) }}" class='basic'>More Details</a>
</div>
</div>
</div>
@endforeach
</div>
这是我的控制器代码,用于从数据库中获取数据
public function property_type()
{
$term=Input::get('ptyname');
$data = array();
$display = DB::table('property_details')
->where('property_type', 'LIKE', '%'.$term.'%')
->Where('sale_or_rent', '=', 'sale')
->get();
var_dump($display);
if(count($display)!=0)
{
return View::make('/pages/property_home', array('row'=>$display));
}
else
{
session::flash('status', 'No Records Found!!!');
return View::make('/pages/property_home', array('row'=>$display));
}
}
这是加载控制器的My Ajax
<script>
(function($) {
$('#property_id').on('change', function() {
var optionSelected = $(this).find("option:selected");
var prop_type = optionSelected.val();
$.ajax({
type: "GET",
url: "{{URL::to('/property_type') }}",
dataType: "json",
data: {ptyname: prop_type},
success:function(row)
{
$('#getRequestdata').html(row.html);
}
});
});
})(jQuery);
</script>
这是我的路线
Route::get('/property_type', array('as' => 'property_type', 'uses' => 'PageController@property_type'));
像这样我在控制台中获取数据 数组(2){ [0] =&GT; object(stdClass)#293(24){ [ “ID”] =&GT; INT(3) [“sale_or_rent”] =&gt;字符串(4)“促销” [“property_type”] =&gt;字符串(11)“共管公寓” [“property_room”] =&gt;字符串(1)“2” [ “property_baths”] =&GT; string(1)“2” [“property_size”] =&gt;字符串(8)“200平方英尺” [“property_garage”] =&gt;字符串(1)“2” [“property_year”] =&gt; string(4)“1959” [“property_floor”] =&gt; string(1)“4” [“sale_by”] =&gt;字符串(5)“所有者” [“property_price”] =&gt;字符串(7)“$ 200000” [“phonenumber”] =&gt; string(10)“9941661138” [“address”] =&gt; string(47)“610 Airport Rd,Nenana,AK 99760,United States” [“lat”] =&gt;字符串(10)“64.5486956” [“log”] =&gt;字符串(12)“ - 149.0927984” [“state”] =&gt; string(6)“Alaska” [“city”] =&gt; string(6)“Manely” [“zipcode”] =&gt; string(6)“600097” [“description”] =&gt;字符串(34)“这是我的财产......联系我” [“image”] =&gt;字符串(25)“2016-01-22-06-34-16-8.jpg” [“amenties”] =&gt; string(63)“空调,退房后清洁,洗碗机,烧烤架,互联网” [“user_id”] =&gt;字符串(0)“” [“created_at”] =&gt; string(19)“2016-01-22 07:53:05” [“updated_at”] =&gt;字符串(19)“2016-01-22 07:53:05” } }
答案 0 :(得分:0)
你必须为你的观点分配回复,你应该创建一个div来追加/替换你的回复
例如:在您的视图中,在您的选择下拉列表下方创建div,例如var img = new Image(); // draw svg on canvas
img.onload = function () {
exprtCtx.drawImage(img, 0, 0);
};
img.src = svg;
<div id="search-response"> </div>