0

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://actionupdate", {"data":obj});
    document.getElementById("status").innerHTML="sent";
}

So.. my question: what am I missing? What's wrong with my post?

Community
  • 1
  • 1
Chris
  • 1,013
  • 1
  • 15
  • 35

1 Answers1

2

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.

Community
  • 1
  • 1
Anomie
  • 92,546
  • 13
  • 126
  • 145