1

I have a question, Im using jquery, jqueryui and basic ajax.

I would like to use some plugin or easy way to refresh the result of a form without refrehs the page.

For example if I search hotels and I want filter only the 3 starts ones that the result load in the same page without refresh

Thanks!!

This is the slider jquery code:

$(function() {
    $( "#slider-range-min" ).slider({
        range: "min",
        value: 50000,
        min: 1,
        max: 50000,
        slide: function( event, ui ) {
            $( "#amount" ).val(ui.value+ " €" );
        }
    });
    $( "#amount" ).val($( "#slider-range-min" ).slider( "value" )+ " €" );
});
Chris Pratt
  • 232,153
  • 36
  • 385
  • 444
Rom
  • 563
  • 5
  • 21
  • Check out this post http://stackoverflow.com/questions/5283165/how-to-insert-data-into-field-without-refresh/5283224#5283224 – Trevor Jul 19 '11 at 19:28
  • 1
    You can also go through http://stackoverflow.com/questions/680241/blank-out-a-form-with-jquery – Varun Achar Jul 19 '11 at 19:34

1 Answers1

1

If you are interested in some framework, Yii provides some great widgets with behaviour that you are interested in (and many more).

Read more here: http://www.yiiframework.com/ and here: http://www.larryullman.com/2009/10/31/getting-started-with-the-yii-framework/

If you don't want a framework, I guess it can be done with jquery and ajax quite easily, but you should share some html code.

Code:

`$.post('current url', $(formSelector).serialize(), function(data) {

var table = $.xmlDOM( data ).find(tableSelector).html();

$(tableSelector).html(table);

}`

It's not very clean and effective approach but it should do the trick (and Yii does it the same way :D)

Nebril
  • 3,153
  • 1
  • 33
  • 50
  • This is the slider jquery code: $(function() { $( "#slider-range-min" ).slider({ range: "min", value: 50000, min: 1, max: 50000, slide: function( event, ui ) { $( "#amount" ).val(ui.value+ " €" ); } }); $( "#amount" ).val($( "#slider-range-min" ).slider( "value" )+ " €" ); }); – Rom Jul 19 '11 at 19:41
  • Ok, but where do you take these hotel info from? I guess you have some kind of table and you want to filter it, but I can't read your computer files :). – Nebril Jul 19 '11 at 19:56
  • I have a form that load a table with the result of the query. Then I want filter this result in order to show only the 3 starts hotel form example. – Rom Jul 19 '11 at 20:11
  • If you are passing form data directly to the query (which is not very recommended because of sql injection threat), you can submit form via ajax, get table from ajax response and replace existing one. So it would look sth like I will put in my answer in a minute – Nebril Jul 19 '11 at 20:32