I am new to Ajax and decided to add it to my blog site but for the life of me i cant figure out why it keeps returning an error message in both IE and Firefox. The code is on Blogger.com but when i move it to another server it works fine. Here have a look I have put the code onto this test blogger site for you to try:
There are several alert boxes to help tell you where things are....And here is the code i am using on that page:
Code:<script type='text/javascript'> var c; function o() { if(c==undefined) { c=0; try { alert("Starting Ajax call..."); var vv = ax("http://z2.awardspace.us/1.js"); alert("Ajax call Returned - No Error - Parsing Data: ["+vv+"]"); if (vv.length == 4) { c = parseInt(vv.substring(2,3)); alert("Ajax Call Successful"); } else { alert("Ajax Call Returned unexpected data content"); } } catch(ee4) { alert("Ajax Call Failed - Catch:" +ee4); } } } function ax(url) { var xhr; try { xhr = new ActiveXObject("Msxml2.XMLHTTP"); alert("USE: IE Ajax API"); } catch (ee1) { try { xhr = new ActiveXObject("Microsoft.XMLHTTP"); alert("USE: IE Ajax API"); } catch (ee2) { try { xhr = new XMLHttpRequest(); alert("USE: Firefox/Safari Ajax API"); } catch (ee3) { xhr = false; alert("No Ajax capability"); } } } if (xhr) { alert('CALLING: Ajax .open()') xhr.open('GET', url, false); alert('DONE: Ajax .open()'); alert('CALLING: Ajax .send()') xhr.send(null); alert('DONE: Ajax .send()'); return xhr.responseText; } else { return ""; } } </script>


Reply With Quote



Bookmarks