jquery - How to identify if any script failure in a MVC web page -
we have web site open public customers. complaining button not working (on ie reported far). cannot regenerate in dev environment or live site. button calling jquery method seems doesn't hit method when issue occur.
below method button should fire nothing reported in our logs coded.
function getaddress() { if ($('#postcode').val() == "") { $('#postcode').addclass("txt_required"); return false; } else { $.post(serverpath + "issessionalive", { policyrefno: refno }, function (data) { if (data.session == 1) { $.ajax({ type: 'post', url: serverpath + "getpostcoderelatedaddress", datatype: 'json', data: { code: $("#postcode").val() } }) .done(function (data) { try { //console.log(data); $("#postcode").val(data.postcode); $("#address2").val(data.address2); $("#town").val(data.town); $("#city").val(data.city); var prems = data.premises; $('#address1').empty(); (i = 0; <= prems.length - 1; i++) { $('<option/>').val(prems[i]).html(prems[i]).appendto('#address1'); } } catch (e) { window.location.replace(serverpath + "error?errcode=" + e.tostring()); } }) .fail(function (data) { window.location.replace(serverpath + "error?errcode=ajax fail"); }); } else { window.location.replace(serverpath + "sessiontimeout"); } }); }
my question here available approaches catch these types of issues devs cannot see unknown users reporting exists?
i faced type scenario in time.
we have integrate our page customer sites. on user reports our button click not working.
remedy take after
defined global javascript error catch. sure load first.
<script type="text/javascript"> window.onerror = function(msg, url, line, col, error) { //log; }; </script>
if javascript error occurs before button click script, script load defintly button click not bind.
then check button click event binded or not using $._data.
$._data( $("#button_id")[0], "events" );
if global error catch find error means , check affecting button click.
this faced , rid off.
Comments
Post a Comment