Mentor
30-05-2006, 05:32 PM
Basicaly my ajax news system for tb5 works perfectly in firefox but ****s up in IE. As i cant realy be arsed to hunt aorund for hours looking for whats wrong, when chances are its stairing me obviosly in the face, im asking here to see anyone with a freash approach and figure out the problem quickly.
The javascript code is as below:
var target ;
function a_edit(id){
target = 'N_' + id;
try {xmlhttp = window.XMLHttpRequest?new XMLHttpRequest(): new ActiveXObject("Microsoft.XMLHTTP");} catch (e) { // DontWork
}
xmlhttp.onreadystatechange = b_edit;
xmlhttp.open("GET", '####&a=addform&id=' + id);
xmlhttp.send(null);
}
function b_edit(){
if ((xmlhttp.readyState == 4) && (xmlhttp.status == 200)) {
document.getElementById(target).innerHTML = xmlhttp.responseText;
}
}
function c_edit(id){
// Get Data
var title = document.getElementById("N" + id + "_title").value;
var cat = document.getElementById("N" + id + "_Cat").value;
var update = document.getElementById("N" + id + "_time").checked;
var news = document.getElementById("N" + id + "_NewsItem").value;
xmlhttp.onreadystatechange = d_edit;
xmlhttp.open("POST", '####&a=save&id=' + id + '', true);
xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xmlhttp.send("title=" + title + "&cat=" + cat + "&update=" + update + "&news=" + news + "");
}
function d_edit(){
if ((xmlhttp.readyState == 4) && (xmlhttp.status == 200)) {
var rsp = xmlhttp.responseText;
// Spit Id and responce
var rsp2 = rsp.split('||--||');
var loc = 'N_' + rsp2[0];
//Write responce to ID
document.getElementById(loc).innerHTML = rsp2[1];
}
}
var adin = 0;
function n_Add(){
if(adin== 1) {
}
else {
// Load Ajax form for New news
try {xmlhttp = window.XMLHttpRequest?new XMLHttpRequest(): new ActiveXObject("Microsoft.XMLHTTP");} catch (e) { // DontWork
}
xmlhttp.onreadystatechange = n_Add2;
xmlhttp.open("GET", '####&a=New_addform');
xmlhttp.send(null);
}
}
var cur;
function n_Add2(){
if ((xmlhttp.readyState == 4) && (xmlhttp.status == 200)) {
cur = document.getElementById('addSpace').innerHTML
document.getElementById('addSpace').innerHTML = xmlhttp.responseText + cur;
adin = 1;
}
}
function n_Add3(){
//
var title = document.getElementById("New_title").value;
var cat = document.getElementById("New_Cat").value;
var news = document.getElementById("New_NewsItem").value;
xmlhttp.onreadystatechange = n_Add4;
xmlhttp.open("POST", '####&a=addme', true);
xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xmlhttp.send("title=" + title + "&cat=" + cat + "&news=" + news + "");
}
function n_Add4(){
if ((xmlhttp.readyState == 4) && (xmlhttp.status == 200)) {
document.getElementById('addSpace').innerHTML = xmlhttp.responseText + cur;
adin = 0;
}
}
function delete_N(id) {
if (confirm('Are you sure you want to delete this News Item?')) {
// Ajax remove post
xmlhttp.open("GET", '####&a=del&id=' + id);
xmlhttp.send(null);
// Make gone
document.getElementById('N_' + id).innerHTML = "";
}
else {
// Cancil remove prot
alert ('Ok, no action has been taken');
}
}
To be on the safe side i #### the urls until i get around to checking them security wize
the code it works on
<div align="left">
<div style="padding:6px"><a href="javascript:n_Add();">ADD NEWS BUTTON</a></div><br />
<div id="addSpace"></div>
<div id="N_6">
<a href="javascript:a_edit(6);"><img src="http://thybag.co.uk/forum/style_images/bag/p_edit.gif" alt="Edit" style="border:0; float:right; position:relative;"></a><a href="javascript:delete_N(6);"><img src="http://thybag.co.uk/forum/style_images/bag/p_delete.gif" alt="Delete" style="border:0; float:right; position:relative;"></a>
<img src="http://thybag.co.uk/mkportal/modules/gallery/album/t_a_348.jpg" alt="Mentor Avitar" width="106" height="150" style="padding:4px; float:left; position:relative; z-index:4;">
<h3><a href="#">Netscape Firefox Add</a></h3>
<div style="padding:0px 0px 5px 0px;">
<div align="left">
Lets see about them there perms ey?<br>My <br>av<br>it <br>ar<br>Its a <br>little<br>big for this<br>new system maybe...<br><br>i think.. or do i <!--emo&:/--><img src='http://thybag.co.uk/forum/html/emoticons/hmm.gif' border='0' style='vertical-align:middle' alt='hmm.gif' /><!--endemo--> <!--emo&:)--><img src='http://thybag.co.uk/forum/html/emoticons/smile.gif' border='0' style='vertical-align:middle' alt='smile.gif' /><!--endemo--> YOu suck!
</div>
<div style="background-color:#CCCCCC; padding:2px;">
<div style=" float:right; font-weight:bold;">
0 <a href="#">Comments</a>
</div>
By <a href="forum/index.php?showuser=66"><strong>Mentor</strong></a> at 6:24 - 06/04/2006
</div>
</div>
</div>
<div id="N_4">
<a href="javascript:a_edit(4);"><img src="http://thybag.co.uk/forum/style_images/bag/p_edit.gif" alt="Edit" style="border:0; float:right; position:relative;"></a><a href="javascript:delete_N(4);"><img src="http://thybag.co.uk/forum/style_images/bag/p_delete.gif" alt="Delete" style="border:0; float:right; position:relative;"></a>
<img src="http://img107.exs.cx/img107/1092/ufo6ld.gif" alt="Bag Avitar" width="75" height="53" style="padding:4px; float:left; position:relative; z-index:4;">
<h3><a href="#">Shizzle</a></h3>
<div style="padding:0px 0px 5px 0px;">
<div align="left">
I think we have a working news system here! <br>I iz like well Chuffed with dat achivement Ey <!--emo&:D--><img src='http://thybag.co.uk/forum/html/emoticons/biggrin2.gif' border='0' style='vertical-align:middle' alt='biggrin2.gif' /><!--endemo--><br><br>Uz also smellzz
</div>
<div style="background-color:#CCCCCC; padding:2px;">
<div style=" float:right; font-weight:bold;">
0 <a href="#">Comments</a>
</div>
By <a href="forum/index.php?showuser=1"><strong>Bag</strong></a> at 12:07 - 05/04/2006
</div>
</div>
</div>
<div id="N_1">
<a href="javascript:a_edit(1);"><img src="http://thybag.co.uk/forum/style_images/bag/p_edit.gif" alt="Edit" style="border:0; float:right; position:relative;"></a><a href="javascript:delete_N(1);"><img src="http://thybag.co.uk/forum/style_images/bag/p_delete.gif" alt="Delete" style="border:0; float:right; position:relative;"></a>
<img src="http://img107.exs.cx/img107/1092/ufo6ld.gif" alt="Bag Avitar" width="75" height="53" style="padding:4px; float:left; position:relative; z-index:4;">
<h3><a href="#">Thybag Ajax News Engine Online</a></h3>
<div style="padding:0px 0px 5px 0px;">
<div align="left">
Yes, i think ive finaly managed to get this thing working. Thybags new system can now be edited without any refreshing, directly where it is via the edit button on the right of each artical. So far the forum parser is working perfectly and provideing the smilys and BB code as it is needed.<br><br>Wooot is my responce <!--emo&:D--><img src='http://thybag.co.uk/forum/html/emoticons/biggrin2.gif' border='0' style='vertical-align:middle' alt='biggrin2.gif' /><!--endemo--><br>PS. I am naked... really naked!<br>PSS. No wait, Thats not me. Just ryan... Why is ryan naked in my room?<br>PSSS. Feel the wind!<br>PSSSS. *Swipes Fan* MINE! *throws tantrum*<br>PSSSSS. I like Pie an i cannot lie!
</div>
<div style="background-color:#CCCCCC; padding:2px;">
<div style=" float:right; font-weight:bold;">
0 <a href="#">Comments</a>
</div>
By <a href="forum/index.php?showuser=1"><strong>Bag</strong></a> at 9:41 - 04/04/2006
</div>
</div>
</div>
<div style="padding:12px">Pages: 1 2 3 4 5 6 .</div> </div></div>
</div>
</div></div></div></div></div></div></div></div>
</div><br>
<br>
Any obvios errors or idiotc stuff in there? or something wrong that would cause problems with IE copatablty?
Thanks for any help
The javascript code is as below:
var target ;
function a_edit(id){
target = 'N_' + id;
try {xmlhttp = window.XMLHttpRequest?new XMLHttpRequest(): new ActiveXObject("Microsoft.XMLHTTP");} catch (e) { // DontWork
}
xmlhttp.onreadystatechange = b_edit;
xmlhttp.open("GET", '####&a=addform&id=' + id);
xmlhttp.send(null);
}
function b_edit(){
if ((xmlhttp.readyState == 4) && (xmlhttp.status == 200)) {
document.getElementById(target).innerHTML = xmlhttp.responseText;
}
}
function c_edit(id){
// Get Data
var title = document.getElementById("N" + id + "_title").value;
var cat = document.getElementById("N" + id + "_Cat").value;
var update = document.getElementById("N" + id + "_time").checked;
var news = document.getElementById("N" + id + "_NewsItem").value;
xmlhttp.onreadystatechange = d_edit;
xmlhttp.open("POST", '####&a=save&id=' + id + '', true);
xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xmlhttp.send("title=" + title + "&cat=" + cat + "&update=" + update + "&news=" + news + "");
}
function d_edit(){
if ((xmlhttp.readyState == 4) && (xmlhttp.status == 200)) {
var rsp = xmlhttp.responseText;
// Spit Id and responce
var rsp2 = rsp.split('||--||');
var loc = 'N_' + rsp2[0];
//Write responce to ID
document.getElementById(loc).innerHTML = rsp2[1];
}
}
var adin = 0;
function n_Add(){
if(adin== 1) {
}
else {
// Load Ajax form for New news
try {xmlhttp = window.XMLHttpRequest?new XMLHttpRequest(): new ActiveXObject("Microsoft.XMLHTTP");} catch (e) { // DontWork
}
xmlhttp.onreadystatechange = n_Add2;
xmlhttp.open("GET", '####&a=New_addform');
xmlhttp.send(null);
}
}
var cur;
function n_Add2(){
if ((xmlhttp.readyState == 4) && (xmlhttp.status == 200)) {
cur = document.getElementById('addSpace').innerHTML
document.getElementById('addSpace').innerHTML = xmlhttp.responseText + cur;
adin = 1;
}
}
function n_Add3(){
//
var title = document.getElementById("New_title").value;
var cat = document.getElementById("New_Cat").value;
var news = document.getElementById("New_NewsItem").value;
xmlhttp.onreadystatechange = n_Add4;
xmlhttp.open("POST", '####&a=addme', true);
xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xmlhttp.send("title=" + title + "&cat=" + cat + "&news=" + news + "");
}
function n_Add4(){
if ((xmlhttp.readyState == 4) && (xmlhttp.status == 200)) {
document.getElementById('addSpace').innerHTML = xmlhttp.responseText + cur;
adin = 0;
}
}
function delete_N(id) {
if (confirm('Are you sure you want to delete this News Item?')) {
// Ajax remove post
xmlhttp.open("GET", '####&a=del&id=' + id);
xmlhttp.send(null);
// Make gone
document.getElementById('N_' + id).innerHTML = "";
}
else {
// Cancil remove prot
alert ('Ok, no action has been taken');
}
}
To be on the safe side i #### the urls until i get around to checking them security wize
the code it works on
<div align="left">
<div style="padding:6px"><a href="javascript:n_Add();">ADD NEWS BUTTON</a></div><br />
<div id="addSpace"></div>
<div id="N_6">
<a href="javascript:a_edit(6);"><img src="http://thybag.co.uk/forum/style_images/bag/p_edit.gif" alt="Edit" style="border:0; float:right; position:relative;"></a><a href="javascript:delete_N(6);"><img src="http://thybag.co.uk/forum/style_images/bag/p_delete.gif" alt="Delete" style="border:0; float:right; position:relative;"></a>
<img src="http://thybag.co.uk/mkportal/modules/gallery/album/t_a_348.jpg" alt="Mentor Avitar" width="106" height="150" style="padding:4px; float:left; position:relative; z-index:4;">
<h3><a href="#">Netscape Firefox Add</a></h3>
<div style="padding:0px 0px 5px 0px;">
<div align="left">
Lets see about them there perms ey?<br>My <br>av<br>it <br>ar<br>Its a <br>little<br>big for this<br>new system maybe...<br><br>i think.. or do i <!--emo&:/--><img src='http://thybag.co.uk/forum/html/emoticons/hmm.gif' border='0' style='vertical-align:middle' alt='hmm.gif' /><!--endemo--> <!--emo&:)--><img src='http://thybag.co.uk/forum/html/emoticons/smile.gif' border='0' style='vertical-align:middle' alt='smile.gif' /><!--endemo--> YOu suck!
</div>
<div style="background-color:#CCCCCC; padding:2px;">
<div style=" float:right; font-weight:bold;">
0 <a href="#">Comments</a>
</div>
By <a href="forum/index.php?showuser=66"><strong>Mentor</strong></a> at 6:24 - 06/04/2006
</div>
</div>
</div>
<div id="N_4">
<a href="javascript:a_edit(4);"><img src="http://thybag.co.uk/forum/style_images/bag/p_edit.gif" alt="Edit" style="border:0; float:right; position:relative;"></a><a href="javascript:delete_N(4);"><img src="http://thybag.co.uk/forum/style_images/bag/p_delete.gif" alt="Delete" style="border:0; float:right; position:relative;"></a>
<img src="http://img107.exs.cx/img107/1092/ufo6ld.gif" alt="Bag Avitar" width="75" height="53" style="padding:4px; float:left; position:relative; z-index:4;">
<h3><a href="#">Shizzle</a></h3>
<div style="padding:0px 0px 5px 0px;">
<div align="left">
I think we have a working news system here! <br>I iz like well Chuffed with dat achivement Ey <!--emo&:D--><img src='http://thybag.co.uk/forum/html/emoticons/biggrin2.gif' border='0' style='vertical-align:middle' alt='biggrin2.gif' /><!--endemo--><br><br>Uz also smellzz
</div>
<div style="background-color:#CCCCCC; padding:2px;">
<div style=" float:right; font-weight:bold;">
0 <a href="#">Comments</a>
</div>
By <a href="forum/index.php?showuser=1"><strong>Bag</strong></a> at 12:07 - 05/04/2006
</div>
</div>
</div>
<div id="N_1">
<a href="javascript:a_edit(1);"><img src="http://thybag.co.uk/forum/style_images/bag/p_edit.gif" alt="Edit" style="border:0; float:right; position:relative;"></a><a href="javascript:delete_N(1);"><img src="http://thybag.co.uk/forum/style_images/bag/p_delete.gif" alt="Delete" style="border:0; float:right; position:relative;"></a>
<img src="http://img107.exs.cx/img107/1092/ufo6ld.gif" alt="Bag Avitar" width="75" height="53" style="padding:4px; float:left; position:relative; z-index:4;">
<h3><a href="#">Thybag Ajax News Engine Online</a></h3>
<div style="padding:0px 0px 5px 0px;">
<div align="left">
Yes, i think ive finaly managed to get this thing working. Thybags new system can now be edited without any refreshing, directly where it is via the edit button on the right of each artical. So far the forum parser is working perfectly and provideing the smilys and BB code as it is needed.<br><br>Wooot is my responce <!--emo&:D--><img src='http://thybag.co.uk/forum/html/emoticons/biggrin2.gif' border='0' style='vertical-align:middle' alt='biggrin2.gif' /><!--endemo--><br>PS. I am naked... really naked!<br>PSS. No wait, Thats not me. Just ryan... Why is ryan naked in my room?<br>PSSS. Feel the wind!<br>PSSSS. *Swipes Fan* MINE! *throws tantrum*<br>PSSSSS. I like Pie an i cannot lie!
</div>
<div style="background-color:#CCCCCC; padding:2px;">
<div style=" float:right; font-weight:bold;">
0 <a href="#">Comments</a>
</div>
By <a href="forum/index.php?showuser=1"><strong>Bag</strong></a> at 9:41 - 04/04/2006
</div>
</div>
</div>
<div style="padding:12px">Pages: 1 2 3 4 5 6 .</div> </div></div>
</div>
</div></div></div></div></div></div></div></div>
</div><br>
<br>
Any obvios errors or idiotc stuff in there? or something wrong that would cause problems with IE copatablty?
Thanks for any help