Tuesday, 15 January 2013

jQuery focus() causes .load() to excecute twice in IE9 -



jQuery focus() causes .load() to excecute twice in IE9 -

jquery focus seems cause net explorer 9 execute twice. problem doesn't happen in older versions of ie, , doesn't happen in firefox or chrome.

i'm having user come in code in input field. on come in or submit code gets sent through load script (ajax). code in input field removed, , focus brought back.

the result of script inserted in div on same page.

$(document).ready(function(){ $('#code').keyup(function(e){ if(e.keycode == 13){ console.log('code submitted through enter'); sendcode($('#code').val()); } }); function sendcode(b){ console.log('function sendcode used'); $('#result').load('scan.php?code=' + b); $('#code').val(''); $('#code').focus(); }; $('#submit').click(function(){ console.log('code submitted through click'); sendcode($('#code').val()); }); });

however, focus() seems problem since when remove problem gone. have tried placing focus() in place of code without success. there alternative focus() achieves same or can somehow fixed?

network: url: /scan.php?code=stackoverflow url: /scan.php?code= console: (when nail enter) log: code submitted through click log: function sendcode used log: code submitted through come in log: function sendcode used

you can see sec load doesn't carry code variable either.

change submit button span or div , style it.

<span id="submit">submit</span>

demo: fiddle

you can @ this answer, adding attribute type="button" button element suggested.

jquery jquery-load

No comments:

Post a Comment