I am 1 week into “brand new” to iOS. I am using x-code to create a view based app. Now using a web view I need to pull a variable from a hidden tag on the webpage and send it to native code. So how do I do this:
xmlhttp=new XMLHttpRequest();
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.getElementById("txtHint").innerHTML=xmlhttp.responseText;
**this varSendText**
varSendText = document.getElementById("sendtextcoupon").value;
if (varSendText == "1")..........
That is the goal but obviously not the way.
Use the
stringByEvaluatingJavaScriptFromString:method of theUIWebView.Just make sure the variable is global and the AJAX response has been received. You can also check this by using the above method and simple Javascript.
Class Reference: http://developer.apple.com/library/ios/#documentation/uikit/reference/UIWebView_Class/Reference/Reference.html