jquery on working on php result button -
i have ajax script , using script show result in php, in result printing button & want use jquery method on button, jquery not working.
my ajax code below
$(document).ready(function(){ $.ajax({ url : "<?php echo base_url('/map/connection_list/')?>", type: "post", datatype: "html", success: function(data) { $("#res").html(data); //$("#content").html(data.content); // $('[id="content"]').val(data.content); }, error: function (jqxhr, textstatus, errorthrown) { alert('error data ajax'); } }); $("#yes").click(function(){ alert("ok"); }); });
result php code below
<button id='yes' class='btn btn-primary'>yes</button> <button id='no' class='btn btn-default'>no</button>
now want use jquery function on button used in below function alert . $('#yes')click(function(){ alert("ok"); }); function not working.
$(document).ready(function () { var fireajax = function () { $.ajax({ url: "<?php echo base_url('/map/connection_list/')?>", type: "post", datatype: "html", success: function (data) { $("#res").html(data); //$("#content").html(data.content); // $('[id="content"]').val(data.content); }, error: function (jqxhr, textstatus, errorthrown) { alert('error data ajax'); } }); }; $("#yes").click(fireajax); $("#no").click(function () { /* sth. else */ }); });
wiki
Comments
Post a Comment