[Prototype-core] Ajax.Request can't work async in IE and Maxthon?
Dear users, Have any one tried Ajax.Request on IE? even i set the async as true the browser freezes until the request is completed. One interesting test u can try is say we have 5 divs. id 1,2,3,4,5 for(var i=0; i5; i++){ new Ajax.request(url, options(asynchronous:true, onComplete:function(trans) { $('i').innterHTML = trans.responseText; })) } assume each time we retrieve different data from server. Run in Firefox and IE, i have observed different results. In FF all the 5 divs will have the same innerTEXT, which is the last request, as when data flows back from the server i is already changed to the last index. But in IE, 5 divs have the different content as it's processed sync. Someone pls help me how to set it work properly async in ie? Thanks! Jack --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Prototype: Core group. To post to this group, send email to prototype-core@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/prototype-core?hl=en -~--~~~~--~~--~--~---
[Prototype-core] Re: Help! Very werid behavior of Ajax.Request, I am desperate...
And I found this weird behavior in ie and firefox. In ie it seem to work but in firefox no. On Jul 19, 4:08 pm, Paladin [EMAIL PROTECTED] wrote: Very simple task to do but never get it work. say I have a class called track function Track(){ this.id = 'a'; this.content = 'b'; } Track.prototype.update(){ this.content = 'b'; alert(this.content) //alert1 options.onSuccess = this.handle.bind(this); new Ajax.Request(url, options); alert(this.content); //alert3 } Track.prototype.handler(transport){ this.content = transport.responseText; alert(this.id); alert(this.content); //alert2 } The overall structure is like this. The funny thing is when executed; alert1 shows 'b', alert2 will show the responseText, but alert3 will still be b. The modification of this.content in the handler can't have global effect. However, when alert this.id in the handler, you will see this.id working. It seems that things are messed up in the scoping of ajax request. Anyone has any clue how to work around ? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Prototype: Core group. To post to this group, send email to prototype-core@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/prototype-core?hl=en -~--~~~~--~~--~--~---
[Prototype-core] Re: Help! Very werid behavior of Ajax.Request, I am desperate...
I figured out the issue. It turned out that IE and firefox handles the function ajax calls in different way. I have to modify the prototype.js, to add a session id passed to Ajax.Request. So instead of function(transport, json), i modified it to function(transport, json, id) - to mark a unique session. It's part of a complicated design, where i dynamically add remove ordered divs and fetch contents from server. Thanks!! On Jul 19, 5:26 pm, Skip Baney [EMAIL PROTECTED] wrote: If I understand you correctly, you are asking why alert3 doesn't show your response text. That's because the ajax request executes asynchronously this.content is still 'b' at that point and has yet to be changed by your handler method. If you need to execute the ajax request synchronously, there is a flag in the options hash to tell it to do so. I'm not sure why it seems to be working for you in IE... perhaps it's just returning faster... or maybe I'm just misunderstanding your question. Hope this helps, - Skip On 7/19/07, Paladin [EMAIL PROTECTED] wrote: And I found this weird behavior in ie and firefox. In ie it seem to work but in firefox no. On Jul 19, 4:08 pm, Paladin [EMAIL PROTECTED] wrote: Very simple task to do but never get it work. say I have a class called track function Track(){ this.id = 'a'; this.content = 'b'; } Track.prototype.update(){ this.content = 'b'; alert(this.content) //alert1 options.onSuccess = this.handle.bind(this); new Ajax.Request(url, options); alert(this.content); //alert3 } Track.prototype.handler(transport){ this.content = transport.responseText; alert(this.id); alert(this.content); //alert2 } The overall structure is like this. The funny thing is when executed; alert1 shows 'b', alert2 will show the responseText, but alert3 will still be b. The modification of this.content in the handler can't have global effect. However, when alert this.id in the handler, you will see this.id working. It seems that things are messed up in the scoping of ajax request. Anyone has any clue how to work around ? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Prototype: Core group. To post to this group, send email to prototype-core@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/prototype-core?hl=en -~--~~~~--~~--~--~---
[Prototype-core] Event.observe will destroy the scope of Javascript OOP?
I discovered a funny pheno, which I don't know anyone else has stated this before. Say I define a class: function Cat(){ this.color = yellow; } Cat.prototype.showColor = function(){ alert(this.color) } Cat.prototype.init(){ Event.observe(button, click, this.showColor); } Now if i do elsewhere, var cat = new Cat(); Cat.init(); then you click on button, and you will see the color is undefined (instead of showing yellow); the observation of events seemed to make the function lost it's scope. I have a way to work around this but I would like to listen to what the developers may think. Thanks! Prototype is a great package and I love it. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Prototype: Core group. To post to this group, send email to prototype-core@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/prototype-core?hl=en -~--~~~~--~~--~--~---