I have problem using onClick, in the first click run one action for the second click the problem showing my click run two action and for the third click the action run three action and for the next click. whats the problem white my jquery?
My Button Click
<a id="detailproduct" href="'.URL.'#PopProductDetail" onclick="showdetailproduct('.$val->bid.')" data-toggle="modal">'.$val->product name.'</a>
this the code
<script type="text/javascript">
function showdetailproduct(id){
$('#PopProductDetail').on('shown.bs.modal',function(e) {
utils.ViewPopProduct(id);
});
}
var utils = {};
(function ($) {
$.ajaxSetup({"error":function(XMLHttpRequest,textStatus, errorThrown) {
alert(textStatus);
alert(errorThrown);
alert(XMLHttpRequest.responseText);
}});
utils.ViewPopProduct = function ViewPopProduct(id) {
var data={id:id};
$.ajax({
type:"GET",
datatype:"json",
url:"",
data:data,
datatype:"html",
cache:false,
success: function(data) {
data = JSON.parse( data );
$('#code').val(data.code);
$('#name').val(data.name);
$('#groupname').val(data.groupname);
$('#brand').val(data.brand);
$('#PopProductDetail').trigger("reset");
$("#detailproduct").unbind("click", ViewPopProduct);
}
});
return false;
};
})(jQuery, window, document);
</script>
The Action url
http://example.com/product?id=34&_=1450341040382
Thanks