Javascript objective-C在UIWebView中调用ajax后获取HTML值

Javascript objective-C在UIWebView中调用ajax后获取HTML值,javascript,jquery,ios,ajax,uiwebview,Javascript,Jquery,Ios,Ajax,Uiwebview,我想获取在UIWebView中单击HTML按钮后创建的div值 但问题是网页只加载一次,在HTML按钮ajax调用之后,它不会在UIWebView中再次加载,因此如何访问div调用后生成的div值 以下是html代码: <a class="btn_class" params="{ &quot;container&quot;: &quot;betInfoTabReceipts&quot;, &quot;onComplete&quot;: &am

我想获取在
UIWebView
中单击
HTML按钮后创建的
div

但问题是网页只加载一次,在
HTML按钮ajax调用之后,它不会在
UIWebView
中再次加载,因此如何访问
div
调用后生成的
div

以下是html代码:

<a class="btn_class" params="{ &quot;container&quot;: &quot;betInfoTabReceipts&quot;, &quot;onComplete&quot;: &quot;ajaxOnCompleteTabs&quot;, &quot;onLoading&quot;: &quot;ajaxOnLoadTabs&quot;}" action="/some.something" onclick="$P('place_bet', {&quot;action&quot;: this.getAttribute('action'), &quot;params&quot;: this.getAttribute('params'), &quot;confirm&quot;: &quot;true&quot;}); return false;" id="btn_id" href="#"></a>

如何解决此问题?

当调用webview didFinishLoading委托方法时,可以执行此javascript代码。像这样
[webView stringByEvaluatingJavaScriptFromString:@”“]
然后您将得到基于ajax的请求回调

var s_ajaxListener = new Object();
s_ajaxListener.tempOpen = XMLHttpRequest.prototype.open;
s_ajaxListener.tempSend = XMLHttpRequest.prototype.send;
s_ajaxListener.callback = function () {
    window.location='mpajaxhandler://' + this.url;
};

XMLHttpRequest.prototype.open = function(a,b) {
    if (!a) var a='';
    if (!b) var b='';
    s_ajaxListener.tempOpen.apply(this, arguments);
    s_ajaxListener.method = a;
    s_ajaxListener.url = b;
    if (a.toLowerCase() == 'get') {
        s_ajaxListener.data = b.split('?');
        s_ajaxListener.data = s_ajaxListener.data[1];
    }
}

XMLHttpRequest.prototype.send = function(a,b) {
    if (!a) var a='';
    if (!b) var b='';
    s_ajaxListener.tempSend.apply(this, arguments);
    if(s_ajaxListener.method.toLowerCase() == 'post')s_ajaxListener.data = a;
    s_ajaxListener.callback();
}
var s_ajaxListener = new Object();
s_ajaxListener.tempOpen = XMLHttpRequest.prototype.open;
s_ajaxListener.tempSend = XMLHttpRequest.prototype.send;
s_ajaxListener.callback = function () {
    window.location='mpajaxhandler://' + this.url;
};

XMLHttpRequest.prototype.open = function(a,b) {
    if (!a) var a='';
    if (!b) var b='';
    s_ajaxListener.tempOpen.apply(this, arguments);
    s_ajaxListener.method = a;
    s_ajaxListener.url = b;
    if (a.toLowerCase() == 'get') {
        s_ajaxListener.data = b.split('?');
        s_ajaxListener.data = s_ajaxListener.data[1];
    }
}

XMLHttpRequest.prototype.send = function(a,b) {
    if (!a) var a='';
    if (!b) var b='';
    s_ajaxListener.tempSend.apply(this, arguments);
    if(s_ajaxListener.method.toLowerCase() == 'post')s_ajaxListener.data = a;
    s_ajaxListener.callback();
}