php - issue in retrieving value type in text box using ajax -


<script>     $(function(){       $("input[name='room_type']").focus(function () {       var str = "";       $("select[name='htl_name'] option:selected").each(function () {             str += $(this).text() + " ";            });              jquery.ajax({             type: "post",             url:"",             data:  $("form#insertform").serialize(),              success: function(data){                 jquery(".res").html(data);                  $('#test').html(data);               }             });               var str = $("form").serialize();             $(".res").text(str);     });     });     </script> 

here i'm getting value typed in input box htl_name whole page reloading. how solve issue?

try this:

$(function(){       $("input[name='room_type']").focus(function (e) {       var str = "";       $("select[name='htl_name'] option:selected").each(function () {             str += $(this).text() + " ";            });              jquery.ajax({             type: "post",             url:"",             data:  $("form#insertform").serialize(),              success: function(data){                 jquery(".res").html(data);                  $('#test').html(data);               }             });               var str = $("form").serialize();             $(".res").text(str);            e.preventdefault(); //if doesn't work, replace "return false"     });     }); 

Comments

Popular posts from this blog

Change php variable from jquery value using ajax (same page) -

Pull out data related to my apps from Android Play Store and iOS App Store -

How can I fetch data from a web server in an android application? -