我应该如何使用ajax将price滑块的值传递给控制器(How should I pass the value of price slider to the controller using ajax)

这是我的代码,

var $range = $("#price-slider"); $range.ionRangeSlider({ min: 130, max: 575, type: 'double', prefix: "$", prettify: false, hasGrid: true, onChange : function (data) { console.log(data); } });

在这里,它希望将值传递给控制器​​。 我应该如何在onChange函数中使用Ajax

而我的Ajax就是这样的

$.ajax({ url: 'hotelresults', type: 'POST', data: { from: from_val, to: to_val }, success: function(data) { $('.hotel_list').html(data); } });

而且在这里,我不知道如何获得价格滑块的价值和价值滑块。

谁来帮帮我..

关心Suganya

Here is my code,

var $range = $("#price-slider"); $range.ionRangeSlider({ min: 130, max: 575, type: 'double', prefix: "$", prettify: false, hasGrid: true, onChange : function (data) { console.log(data); } });

Here, it would like to pass the value to the controller. How should I use Ajax inside the onChange function

And my Ajax is something like this

$.ajax({ url: 'hotelresults', type: 'POST', data: { from: from_val, to: to_val }, success: function(data) { $('.hotel_list').html(data); } });

And also here,I dont know how to get the from and to value of price slider..

Someone help me..

Regards Suganya

最满意答案

对于离子范围滑块,onChange函数采用参数说数据,其中包含滑块的范围值。

在您的情况下,您可以使用data.fromdata.to来获取ajax函数内的范围值。

$.ajax({ url: 'hotelresults', type: 'POST', data: { from: data.from, to: data.to }, success: function(data) { $('.hotel_list').html(data); } });

Thank you soo much..Who were reply me,

It had tried like this way

onChange : function (data) { var from_num = data.fromNumber; var to_num =data.toNumber; $.ajax({ // alert('hai'); url: 'hotelresults', type: 'POST', data: { from: from_num, to: to_num, }, success: function(data){ $('.hotel_list').html(data); } }); }

And It works for me :) :D

更多推荐