Hi, jan
I’ve been happy playing with jsolait
since. J
Apparently, there is small bug with opera
browser.
Any rpc call back using async call would
have failed in opera, where in other browser does fine.
If try to trace it, and find it here in
urllib.js, in mod.sendRequest, line 245 (original urllib.js)
Xmlhttp apparently always null when called
via opera.
This cause callback function cannot
retreive return value from rpc calls
I havent try jsolait v2 because will
require complete rewrite of phpolait
Best regards
Henry Eko
PS: cut down urllib.js
mod.sendRequest=function(type, url, user, pass, data,
headers, callback){
198 var async=false;
199 //check if the last argument is a
function and treat it as callback;
200 if(arguments[arguments.length-1]
instanceof Function){
201 var async=true;
202 callback = arguments[arguments.length-1];
203 }
204 //treat sencond last(if callback)/last(if
no callback) argument as headers
205 var headindex=arguments.length-((async ||
arguments[arguments.length-1] == null) ?2:1);
206 //is it an array then it's headers
207 if(arguments[headindex] instanceof
Array){
208 headers=arguments[headindex];
209 }else{
210 headers=[];
211 }
212 //are user AND password not specified
then assume data as 3rd argument.
213 if(typeof user == "string"
&& typeof pass == "string"){
214 if(typeof data != "string"){
215 data="";
216 }
217 }else if (typeof user ==
"string"){
218 data = user;
219 user=null;
220 pass=null;
221 }else{
222 user=null;
223 pass=null;
224 }
225 var xmlhttp= getHTTP();
226 try{
227 if(user!=null){
228 xmlhttp.open(type, url, async, user,
pass);
229 }else{
230 xmlhttp.open(type, url, async);
231 }
232 }catch(e){
233 throw new mod.RequestOpenFailed(e);
234 }
235 //set headers
236 for(var i=0;i< headers.length;i++){
237 try{//opera 8b does not support
setRequestHeader todo:
238 xmlhttp.setRequestHeader(headers[i][0],
headers[i][1]);
239 }catch(e){
240 }
241 }
242
243 if(async){//set up a callback
244 xmlhttp.onreadystatechange=function(){
245 /*FIXME : Opera cannot do callback here.
xmlhttp object always null*/
246 //dojo.debug(p);
247 if (xmlhttp!=null)
248 if (xmlhttp.readyState==4) {
249 callback(xmlhttp);
250 xmlhttp = null; //help IE with garbage
collection
251 }else if (xmlhttp.readyState==2){
252 //status property should be available (MS
IXMLHTTPRequest documentation)
253 //in Mozilla it is not if the request
failed(server not reachable)
254 //in IE it is not available at all ?!
255 try{//see if it is mozilla otherwise
don't care.
256 var isNetscape = netscape;
257 try{//if status is not available the
request failed.
258 var s=xmlhttp.status;
259 }catch(e){//call the callback because
Mozilla will not get to readystate 4
260 callback(xmlhttp);
261 xmlhttp = null;
262 }
263 }catch(e){
264
265 }
266 }
267 }
268 }
269
270 try{
271 xmlhttp.send(data);
272 }catch(e){
273 if(async){
274 callback(xmlhttp, e);
275 xmlhttp=null;
276 }else{
277 throw new mod.SendFailed(e);
278 }
279 }
280 return xmlhttp;
281 }
From:
jsolait@yahoogroups.com [mailto:jsolait@yahoogroups.com] On Behalf Of Jan-Klaas Kollhof
Sent: Wednesday, August 22, 2007
15:28
To: jsolait@yahoogroups.com
Subject: [jsolait] Re:
XMLRPCAsyncCallback
> Can I bundle jsolait in distribution with my modified phpolait?
Yes you can.
Jan