| Page 1 of 1 | [ 3 posts ] |
|
I am using the IO module to send different POST requests to a servlet.
Function code is given below. The 'execute' function is used my different part of the application to contact servlet. The issue i am facing here is regarding the 'success' function getting called repeatedly. for example, if the 'execute' function is called for the 3rd time, the success function will be called 3 times; and so the 3 different 'responsefunc' will be executed (The one corresponding to the latest request and the previous two) !!. Is it a YUI bug, configuration issue, or my mistake in coding? Please help. this.execute = function(callback) { var cfg = { method: "POST", data: this.getRequest(), sync: this.sync, headers: { 'X-Transaction': 'POST Example'} }; var success = function (x, o){ try { responseFunc(o.responseXML, callback); }catch(e) { alert("Parsing response failed!"); return; } } var failure = function (x, o){ alert("io failed !"); } Y.on('io:success', success); Y.on('io:failure', failure); var request = Y.io("/Test/TestServlet", cfg); } |
|
Move the event subscription code out of this.execute. Each call to this.execute adds new listeners for the io events.
Otherwise, move the listeners into the configuration object. For example: { method: 'POST', data: this.getRequest(), on: { success: function() {}, failure: function() {} } } (Your usage of configuration.sync is incorrect. It should be a boolean, set to true if you want io to issue a synchronous request.) Regards, Thomas |
|
Thanks a lot Thomas. It works.
Had tried detaching the event listener each time to avoid this issue. But now it is perfectly resolved after defining the event handler in configuration. I have also made sure that the variable assigned to the 'sync' is having a boolean value. Thanks a lot. Rakesh |
| Page 1 of 1 | [ 3 posts ] |
| You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum |
© 2006-2013 Yahoo! Inc. All rights reserved.
All code on this site is licensed under the BSD License unless stated otherwise.
About This Site · Security Contact Info
Powered by phpBB® Forum Software © phpBB Group