I am attempting to send data back to my objective c program from javascript.
I found a very helpful question here that got me started, but I quickly ran into a problem: the post seems to be failing.
I also verified syntax at this helpful site.
I know this because I update the contents of a div on my page before and after the post call and I only see the update pre-post. I also have a breakpoint at the beginning of shouldStartLoadWithRequest and it's not firing.
Here's my simple javascript code:
function updateAction(obj) {
document.getElementById("status").innerHTML="sending:"+obj;
$.post("http://actionupd开发者_JS百科ate", {"data":obj});
document.getElementById("status").innerHTML="sent";
}
So.. my question: what am I missing? What's wrong with my post?
From your syntax, I guess you are using jquery? The UIWebViewDelegate's webView:shouldStartLoadWithRequest:navigationType:
method does not seem to get called for ajax requests, which is what $.post()
does. You have to use a normal post instead.
You may find UIWebViewDelegate not monitoring XMLHttpRequest? helpful.
精彩评论