javascript - jquery submit form show the whole html as result -


i have search form submit button show results database.

i want show loader, delay 2s before showing results

the problem results show whole html page result, not result div.

the code:

$( document ).ready(function() {     $(function(){         $("#search").ajaxform({             beforesend: function() {                 $("#login_result").html("<div id='wrapper'><div class='cssload-loader text-center'></div></div><p>loading...</p>");             },             success: function(data) {                 settimeout(function() {                     $("#results").html(data);                 },2000);             }         });     }); }); 

my result code in:

<div class="container bootstrap snippet "  id="results" style="margin-bottom: 90px;">         <div class="row">         <div id="login_result"></div>          <!-- results here -->     </div> </div> 

search form code:

<div class="col-md-12">     <p style="font-family: 'rawy-bold';font-size:35px;color:white;margin-top:20px;">         search     </p>     <form action="index.php" method="post" class="form-inline" id="search">         <input type="text" class="form-control" name="searchinput" size="50">         <button type="submit" name="search" class="btn btn-danger">search</button>     </form>  </div> 

so need parse resulting html. parse , find wrapping element around results. in example here assumed <div class="result-wrapper"><!-- results --></div>:

$( document ).ready(function() {     $(function(){         $("#search").ajaxform({             beforesend: function() {                 $("#login_result").html("<div id='wrapper'><div class='cssload-loader text-center'></div></div><p>loading...</p>");             },             success: function(data) {                 settimeout(function() {                     // parse , find element                     var result = $( data ).find( '.result-wrapper' );                     $("#results").html( result.html() );                 },2000);             }         });     }); }); 

Comments

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -