simple question about multiple rpc calls

76 views
Skip to first unread message

Peter

unread,
Jan 10, 2012, 5:36:06 PM1/10/12
to easyxdm
I am working on implementing easyXDM for file uploads and have an
issue with declaring multiple rpc objects or rather instancing
multiple rpc objects. The issue arises when I create an RPC object and
call it having a callback function A and then reinstancing the object
with a callback function B. When executing the upload function
callback A is executed instead of callback B.


maybe the question to ask is how do you create/redefine a rpc with a
different callback function.

rough example I have created
my solution (but wanted to know if a better way exists): use
remote.destroy() on the success function

user action
-createFunctionCall1() ------create rpc upload with
callback1 attached
-execute upload -------upload with alert
'callback1'
-createFunctionCall2 ------create rpc uload with
callback2 attached
-execute upload -------upload with alert
'callback1' should be 'callback2'


function createFunctionCall1(){
var callbackFunction = function(){
alert('callback1');
}
createUploadRPC(callbackFunction);
}
function createFunctionCall2(){
var callbackFunction = function(){
alert('callback2');
}
createUploadRPC(callbackFunction);
}

function createUploadRPC(parentFun){
alert('recreate');

remote = new easyXDM.Rpc({
remote: REMOTE + "/upload_rpc.html",
swf: REMOTE + "/../easyxdm.swf",
onReady: function(){
//display the upload form
alert('recreated on ready');
var frm = document.getElementById("frmUpload");
frm.action = REMOTE + "/upload_handler.aspx";
frm.style.display = "block";
alert('on ready'+parentFun.toString());
btn = document.getElementById("btnSubmit");


}
}, {
local: {
returnUploadResponse: parentFun}
});

}
Reply all
Reply to author
Forward
0 new messages