Note that there are some explanatory texts on larger screens.

plurals
  1. POQuestion updated - IE8 XMLHTTP json code not working - innerHTML
    primarykey
    data
    text
    <p>UPDATED: after some looking around, it appears that the issue is with IE8 and replacing innerHTML in tables, rather than the json code (see <a href="http://blogs.msdn.com/b/mszcool/archive/2010/01/21/nice-browser-html-javascript-trick-based-on-yesterday-s-expert-chat-on-derstandard-at-avoid-unknown-runtime-error-in-ie-while-setting-innerhtml-of-a-tr-tag.aspx" rel="nofollow noreferrer">here</a>). An alert proves that the json code is returning the expected text, but I can't for the life of me get it to shove into the spot I want it. Apparently there's a problem with innerHTML and table cells, and you can't replace an entire table's contents; you have to target a specific cell. However, I need to generate the contents of tbody - there isn't a single existing row or cell I can use. </p> <p>================================================================================ I've been handed some code written by a developer who is no longer with the company. The code works with no problem in Firefox and Chrome, but does not work at all in IE (7 or 8). It is not throwing any errors; it just isn't displaying the response. Here are the two functions; can anyone help me out? I've only just gotten back into web work after 10 years with legacy apps, so I don't know where to start.</p> <pre><code>var xmlhttp; var the_object = {}; var suggestions = []; function loadXMLDoc(url) { xmlhttp=null; if (window.XMLHttpRequest) {// code for IE7, Firefox, Mozilla, etc. xmlhttp = new XMLHttpRequest(); } else if (window.ActiveXObject) {// code for IE5, IE6 xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); } if (xmlhttp != null) { xmlhttp.onreadystatechange = onResponse; xmlhttp.open("GET",url,true); xmlhttp.send(null); } else { alert("Your browser does not support XMLHTTP."); } } function onResponse() { if (xmlhttp.readyState!=4) return; if (xmlhttp.status!=200) { alert("Problem retrieving XML data"); return; } //JSON response code the_object = eval('(' + xmlhttp.responseText + ')'); if (the_object.errMsg){ alert(the_object.errMsg); }else{ **document.getElementById("shoppingCartTable").innerHTML = the_object.cartHTML;** } } function searchMerchants(term){ url = "/merchant-list/?format=json&amp;q=" + term; loadXMLDoc(url); } function addToCart(id){ var denElem = document.getElementById('item'+id+'_den'); var quanElem = document.getElementById('item'+id+'_quan'); if (denElem.options){ var den = denElem.options[denElem.selectedIndex].value; }else{ var den = denElem.value; } var quan = quanElem.options[quanElem.selectedIndex].value; var voucherNbr = document.getElementById("voucherNbr").value; var url = "/redeem/add-to-cart/?action=add&amp;format=json&amp;voucherNbr=" + voucherNbr + "&amp;merchantId=" + id + "&amp;denomination=" + den + "&amp;quantity=" + quan; loadXMLDoc(url); } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload