GreenDude Posted January 28, 2007 Share Posted January 28, 2007 ok... I made things much easier:since the script form the previous post shows no hope.. I started testing simpler stuff today.So here is a basic script with Ajax that gives the same annoying "Unknown Runtime Error":[code]<form action="test.php" method="post" > <table cellpadding="0" cellspacing="0" class="table_edit" width="800"> <tr> <td width="40" align="left" valign="middle" > <span style="color:#003366; text-decoration:">CNP<span>: </td> <td width="160" align="left" > <input class="fields2" type="text" id="field" name="cnp" value="" size="15" maxlength="13" /> </td> <td width="140"> <input class="submit" type="button" name="bigsubmit" value="Search" onclick="ajaxTest('victim');" /> </td> </tr> </table> </form> [/code]that's the HTML... here's the ajax & PHP:f[code]unction ajaxTest( id ) { var ajaxRequest; // Browser setup try{ // Opera 8.0+, Firefox, Safari ajaxRequest = new XMLHttpRequest(); } catch (e){ // Internet Explorer Browsers try{ ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try{ ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e){ // Something went wrong alert("Your browser broke!"); return false; } } } ajaxRequest.onreadystatechange = function() { if(ajaxRequest.readyState == 4) { var ajaxDisplay = document.getElementById(id); ajaxDisplay.innerHTML = ajaxRequest.responseText; } } var field = document.getElementById('field').value; var queryString = "?field=" + field; ajaxRequest.open("GET", "aj_test.php" + queryString, true); ajaxRequest.send(null); }[/code][code]<?php $field = esc ( $_GET['field'] ); echo '<tr><td width="100" align="left" ><strong>'.$field.'</strong></td></tr>'; ?>[/code]Can't go simpler that that :pPlease help me solve this never-ending problem :) Thanks Quote Link to comment Share on other sites More sharing options...
irken Posted January 28, 2007 Share Posted January 28, 2007 Well. I believe IE has some issues doing the whole injecting html code into the page. What's the type of element you're trying to put the data into? "victim".. some elements have a read-only innerHTML property, and would most likely result in the above error if you attempt to use it.Last time I did innerHTML on a span for example, IE freaked out. Changing that to a div container solved it. Quote Link to comment Share on other sites More sharing options...
alpine Posted January 28, 2007 Share Posted January 28, 2007 You havent got any result div at all in your codeTaking your code, adding a result div - and it's fine in both IE6 and IE7 + FF[code]<html><head><script language="javascript">function ajaxTest( id ){var ajaxRequest;try{ajaxRequest = new XMLHttpRequest();}catch (e){try{ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");}catch (e){try{ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");}catch (e){alert("Your browser broke!");return false;}}}ajaxRequest.onreadystatechange = function(){if(ajaxRequest.readyState == 4){ var ajaxDisplay = document.getElementById(id); ajaxDisplay.innerHTML = ajaxRequest.responseText;}}var field = document.getElementById('field').value;var queryString = "?field=" + field;ajaxRequest.open("GET", "aj_test.php" + queryString, true);ajaxRequest.send(null);}</script></head><body><form action="test.php" method="post" > <table cellpadding="0" cellspacing="0" class="table_edit" width="800"> <tr> <td width="40" align="left" valign="middle" > <span style="color:#003366; text-decoration:">CNP<span>: </td> <td width="160" align="left" > <input class="fields2" type="text" id="field" name="cnp" value="" size="15" maxlength="13" /> </td> <td width="140"> <input class="submit" type="button" name="bigsubmit" value="Search" onclick="ajaxTest('victim');" /> </td> </tr> </table> </form> <div id="victim"></div> </body> </html>[/code]..And, you call some <i>strange</i> function in your php file btw Quote Link to comment Share on other sites More sharing options...
GreenDude Posted January 28, 2007 Author Share Posted January 28, 2007 oh... the esc() function is just for filtering data (mysql_real_escape_string and others)So... I gave the id "victim" to a table... you're saying I should replace with divs right?[code]<table cellpadding="0" cellspacing="0" class="table_edit" width="800" id="victim"> </table>[/code]forgot to mention the table, sorry :-X Quote Link to comment Share on other sites More sharing options...
irken Posted January 28, 2007 Share Posted January 28, 2007 [quote author=GreenDude link=topic=124431.msg515541#msg515541 date=1170010530]oh... the esc() function is just for filtering data (mysql_real_escape_string and others)So... I gave the id "victim" to a table... you're saying I should replace with divs right?[code]<table cellpadding="0" cellspacing="0" class="table_edit" width="800" id="victim"> </table>[/code]forgot to mention the table, sorry :-X[/quote]It might be what's causing it. Not sure if table has a innerHTML property. Just use a DIV and you'll be safe. Quote Link to comment Share on other sites More sharing options...
GreenDude Posted January 28, 2007 Author Share Posted January 28, 2007 yep... that was it :D and it works for the previous post too \:D/THANKS A LOT!!! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.