uiwebview XMLHttpRequest异常101

时间:2012-04-20 15:21:05

标签: objective-c ios ajax webkit

我使用uiwebview在我的iOS应用程序中执行远程过程。这些远程过程可以对本地http服务器执行某些ajax请求,而本地http服务器将返回执行正确的响应处理程序。这工作正常,直到我尝试再次运行整个脚本,这导致“xmlhttprequest异常101”

处理程序ajax:

NSString* makeHTMLwithRegisteredHandlers(NSString* serverurl)
{
NSMutableString* output = [NSMutableString new];
if(registeredHandlers != nil)
{
    for(int i=0;i<registeredHandlers.count;i++)
    {
        NSString* scriptfunc = [AbstractRemoteProcedure makeGetJSFromClass:[registeredHandlers objectAtIndex:i]];
        [output appendFormat:@"\nfunction %@(paramdata) { \n",scriptfunc];
        [output appendString:@"\t$.ajax({  \n"];
        [output appendString:@"\t\ttype: \"POST\",  \n"];
        [output appendFormat:@"\t\turl: \"%@/%@\",  \n",serverurl,scriptfunc];
        [output appendString:@"\t\tasync:false,  \n"];
        [output appendString:@"\t\tprocessData: false, \n"];
        [output appendString:@"\t\tdata: paramdata, \n"];
        [output appendString:@"\t\terror: function(xhr, ajaxOptions, thrownError) { \n"];
        [output appendString:@"\t\t\talert(\"runtime exception:\"+thrownError);\n"];
        [output appendString:@"\t\t\tbreakmyJS();\n"];
        [output appendString:@"\t\t},\n"];
        [output appendString:@"\t\tsuccess: function(data) { \n"];
        [output appendString:@"\t\t\tresult = data;  \n"];
        [output appendString:@"\t\t}\n"];
        [output appendString:@"\t});\n"];



        [output appendString:@"\treturn result;\n} \n"];


    }
}
return output;
}

serverside脚本:

function onConnect()
{
    //device just connected to network
}

function onRetrieve()
{

var req = new Object();
req.url = servertoRequestFrom;
req.usr = deviceIdentifier();
req.pwd = deviceSecret();
var res = HttpCrossDomainSend(jQuery.stringify(req));
var decoded = jQuery.parseJSON(res);
makeSheet(decoded);


}

function onSend()
{
}

function onAuthorize(action)
{
return false;
}

调试日志:

    2012-04-20 17:03:37.290 myApplication[7066:707] server running:http://127.0.0.1:900/

    2012-04-20 17:03:39.464 myApplication[7066:707] InitializeRuntimeProcedure start
    2012-04-20 17:03:39.466 myApplication[7066:707] InitializeRuntimeProcedure done
    2012-04-20 17:03:39.492 myApplication[7066:707] DeviceTypeProcedure start
    2012-04-20 17:03:39.493 myApplication[7066:707] DeviceTypeProcedure done
    2012-04-20 17:03:39.515 myApplication[7066:707] DeviceVersionProcedure start
    2012-04-20 17:03:39.516 myApplication[7066:707] DeviceVersionProcedure done
    2012-04-20 17:03:39.537 myApplication[7066:707] DeviceNameProcedure start
    2012-04-20 17:03:39.539 myApplication[7066:707] DeviceNameProcedure done
    2012-04-20 17:03:39.560 myApplication[7066:707] DeviceIdentiferProcedure start
    2012-04-20 17:03:39.563 myApplication[7066:707] DeviceIdentiferProcedure done
    2012-04-20 17:03:39.583 myApplication[7066:707] DeviceSecretProcedure start
    2012-04-20 17:03:39.586 myApplication[7066:707] DeviceSecretProcedure done
    2012-04-20 17:03:39.608 myApplication[7066:707] CrossDomainRequest start
    2012-04-20 17:03:40.616 myApplication[7066:707] CrossDomainRequest done
    2012-04-20 17:03:40.653 myApplication[7066:707] MakeSheetProcedure start
    2012-04-20 17:03:40.662 myApplication[7066:707] MakeSheetProcedure done
    2012-04-20 17:03:51.841 myApplication[7066:575b] onRetrieve();
    onSend();
    2012-04-20 17:04:02.026 myApplication[7066:707] DeviceTypeProcedure start
    2012-04-20 17:04:02.028 myApplication[7066:707] DeviceTypeProcedure done

0 个答案:

没有答案