c# - jQuery Browser Difference -
since have started working in (internship started 2 months ago) try give information need me out.
i have mvc4 application uses longpolling receive new data (in case messages) server. depending on kind of message, treat differently on client-side.
1 kind of these messages system messages:
i have 2 views. 1 view has button, other has text.
click on button then
- sets properties in controller ,
- forces page reload on other view, resulting in new content (e.g. text boxes)
now, if have opened these 2 views in new window, work out fine (in firefox, ie , chrome).
if have opened them in new tab, work in ie , chrome. firefox receive message, won't invoke callback method.
$(document).ready(function () { readchat(); }) this initializes first call readchat().
mentioned earlier, works fine in tabs in ie , chrome, in new windows in firefox.
if check firebug, response server arrives , can inside json. doesn't invoke callback reason.
my first thought being not loaded yet, added timeout first call.
if write this:
$(document).ready(function () { settimeout(readchat, 1000); } it works in firefox, long not set lower ~1000.
has come across same problem? why firefox make difference here?
edit:
function readchat() { $.fn.messaging({ receiveurl: '@url.action("myaction", "mymethod")', myid: '@model.myid', callback: function(data) { $.each(data.messages, function(k, v) { if(v.kind == 3) { location.reload(true); } }); readchat(); }, timeout: 25000 }, 'read'); } inside $.fn.messaging, function read called given parameters:
$.post(receiveurl, { id: myid }, function(response) { if($.isfunction(settings.callback) { settings.callback(response); } } edit2:
as diesel337 said, i'm using
$(this).ready(function () { readchat(); }); opening in new tab: having made adjustment, tested bit more , @ first glance worked perfectly. noticed, if click on view, should reloaded, before clicking button, won't work. (the message received, callback function not called)
on other hand, if ignored view, should reloaded, , directly clicked button, page reload without problem.
it sounds weird, know, if don't @ view, before clicking button, works.
i have filed new bug report on bugzilla this.
turns out not firefox causing problem firebug.
tried reproduce error today once again , luckily had firebug not active, worked charm.
after turning on again information on why is, got same error.
note: if you're developing requires ajax call on $(document).ready() better don't activate firebug, because mess reason.
Comments
Post a Comment