Jump to content

[SOLVED] the IE thing


GreenDude

Recommended Posts

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" >
&nbsp;&nbsp;<span style="color:#003366; text-decoration:">CNP<span>:&nbsp;&nbsp;
</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 :p

Please help me solve this never-ending problem :)
Thanks
Link to comment
Share on other sites

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.
Link to comment
Share on other sites

You havent got any result div at all in your code

Taking 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" >
&nbsp;&nbsp;<span style="color:#003366; text-decoration:">CNP<span>:&nbsp;&nbsp;
</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
Link to comment
Share on other sites

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

Link to comment
Share on other sites

[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.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.