ajax - jQuery effects doesn't work when I refresh the page next time -


i use jquery , ajax. when refresh page, jquery ui effects applied ajax response.

but when send post back, jquery ui effects don't apply new response.

i can't figure out what's wrong code.

here code

$(document).ready(function() {     $("#sendemp").click(function(e) {             e.preventdefault();             var submit_val = $("#searchbox").val();             //alert('submitval ' + submit_val);               $.ajax( {                 type : "post",                 //datatype :"jason",                 url : "./wp-admin/admin-ajax.php",                 data : {                     action : 'employee_pimary_details',                     user_name : submit_val                 },                 success : function(data) {                 //      alert('hhh');                     $('#accordion21').html(data);                     // $( "#searchbox" ).autocomplete({                     // source: data                     // });                 }             });         });    }); 

i use jquery accordion box. response $('#accordion21').html(data); applied jquery ui accordion.

in php code, have following

$jason .=  '<h3 style="font-size:15px;">';     foreach($employee $key=> $value){         $jason .= '<table><tbody>';         $jason .= '<tr><td style="width:400px;padding:5px;padding:10px;"></td><td style="width:300px;padding:5px;"><img style="width:132px; height:175px;" src="'.$image_folder.$value->prfil_img .'" /></td></tr>';     //$retval .= '<a href="'. $store_url . 'product_info.php?products_id=' . $product_id . '"><img src="' . $image_folder . $product_image . '" /></a><br />';          $jason .= '<tr><td style="width:30%;font-size:14px;paddig:10px;">'.'name:'.'</td>'.'<td style="font-size:14px;paddig:5px;">'.$value->first_name.'&nbsp;&nbsp;'.$value->last_name.'</td></tr>';         $jason .= '<tr><td style="width:30%;font-size:14px;paddig:10px;">'.'email:'.'</td>'.'<td style="font-size:14px;paddig:5px;">'.$value->email;'</td></tr>';         $jason .= '<tr><td style="width:30%;font-size:14px;paddig:10px;">'.'tel ext:'.'</td>'.'<td style="font-size:14px;paddig:5px;">'.$value->extension;'</td></tr>';         $jason .= '<tr><td style="width:30%;font-size:14px;paddig:10px;">'.'att:'.'</td>'.'<td style="font-size:14px;paddig:5px;">'.$value->att;'</td></tr>';         $jason .= '</table></tbody>';         // echo '</br>';echo '</br>';     }         $jason .= '</h3>'; 

jquery ui applied <h3> , <div>

http://jqueryui.com/accordion/

you want initialise autocomplete on page load, on subsequent ajax requests want assign source via setter method:

$(document).ready(function() {     $("#searchbox").autocomplete({ source: [] });     $("#sendemp").click(function(e) {             e.preventdefault();             var submit_val = $("#searchbox").val();             //alert('submitval ' + submit_val);               $.ajax( {                 type : "post",                 //datatype :"jason",                 url : "./wp-admin/admin-ajax.php",                 data : {                     action : 'employee_pimary_details',                     user_name : submit_val                 },                 success : function(data) {                 //      alert('hhh');                     $('#accordion21').html(data);                      $( "#searchbox" ).autocomplete("option", "source", data);                  }             });          });    }); 

but jquery ui autocomplete provides code automatically. have @ documentation source property.


Comments

Popular posts from this blog

How to mention the localhost in android -

php - Calling a template part from a post -

c# - String.format() DateTime With Arabic culture -