| |||
| [Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] |
| Hi John. I don't quite understand the problem you seem to have, but I had a similar problem I think with my widget. The thing was that I'm sending multiple asynchronous requests and want to check, when receiving, which one I received. This I accomplished by attaching one or two variables together with the request. Excuse me for my not so good english by the way. I found a good webpage which explains this in detail: http://www.drakware.com/articles/multijax.php My widget queries a webpage in order to receive stock infos. I used the following function inspired by Drakware's code: /* HTTP request object constructor and attaches some properties to it*/ function CHTTPReq(type,stockCode,httpReq) { this.type = type; this.stockCode = stockCode; this.httpReq = httpReq; } function queryCitibank(stockCode,queryType,stockCodeURL) { var httpReq = false; var strURL = (stockCodeURL!=null)? stockCodeURL:'http://www.citibank.de/service/service_suche.asp?SearchType=3&SearchString='+stockCode; httpReq=new XMLHttpRequest(); if (httpReq) { httpReq.> httpReq.open("GET",strURL,true); var tmpHttpReq = new CHTTPReq(queryType,stockCode,httpReq); httpReqs.push(tmpHttpReq); httpReq.send(null); } } function httpReqChange() { if (httpReqs.length<1) return; for (var i=0; i < httpReqs.length; i++) { if (httpReqs[i].httpReq.readyState == 4) { if (httpReqs[i].httpReq.status == 200 || httpReqs[i].httpReq.status == 304) { reqResponseText = httpReqs[i].httpReq.responseText; reqResponseType = httpReqs[i].type; var reqResponseStockCode = httpReqs[i].stockCode; httpReqs.splice(i,1); i--; var processingLastReq = (httpReqs.length<1)? true:false; switch (reqResponseType) { case 'quote': handleStockQuote(reqResponseText,processingLastReq); break; case 'lookup': handleLookupSymbol(reqResponseText); break; case 'lookupName': handleLookupName(reqResponseText,reqResponseStockCode); break; case 'lookupNameMulti': lookupNameMulti(reqResponseText,reqResponseStockCode); break; default: handleStockQuote(reqResponseText,processingLastReq); } } else { // error } } } } Bye Christian |
_______________________________________________ Do not post admin requests to the list. They will be ignored. Dashboard-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/dashboard-dev/email@hidden This email sent to email@hidden
| Home | Archives | FAQ | Terms/Conditions | Contact | RSS | Lists | About |
Visit the Apple Store online or at retail locations.
1-800-MY-APPLE
Contact Apple | Terms of Use | Privacy Policy
Copyright © 2007 Apple Inc. All rights reserved.