javascript - Prevent scroll to the top when getJSON is called -


im confused right now.

here code:

    $("#combinations").on("change", "input", function (e) {         e.preventdefault();    console.log(e)         var $button, $row, $group, $form, $barcodevalidation, url, barcodeval;         $button = $(this);         $row = $button.closest(".input-group");         $group = $row.closest(".form-group");         $form = $group.closest("form");         $barcodevalidation = $row.find("#barcode-validation");         barcodeval = $row.find("input").val();         url = "/product/checkbarcode";         var productnumber = $form.find("#product_number").val();          $.getjson(url, {             barcode: barcodeval,             productnumber: productnumber         }).done(function (result) {             e.preventdefault();         }).fail(function (result) {         });      }); 

so when combinations input changes want make request server , check some. reason every time request happends page keep scrolling top. if outcomment ajax request part, fine.

how prevent such behavior?

edit

markup :

                    <div class="row">                         <div class="col-md-12">                              <div class="combinations">                                 @html.editorfor(m => m.combinations)                             </div>                          </div>                     </div> 

editor contains input fields.


Comments

Popular posts from this blog

node.js - Using Node without global install -

How to access a php class file from PHPFox framework into javascript code written in simple HTML file? -

java - Null response to php query in android, even though php works properly -