Jump to content
funbinod

simple ajax doesnt work on IE

Recommended Posts

i'm learning ajax along with javascript. while learning i'm trying something as responseText. what i tried works fine on CHROME version 36(dev) but doesn't work on Internet Explorer version 11.

this is what i tried

<head><script type="text/javascript">var XMLHttpRequestObject = false;if (window.XMLHttpRequest) {	XMLHttpRequestObject = new XMLHttpRequest();} else if (window.ActiveXObject) {	XMLHttpRequestObject = new ActiveXObject("Microsoft.XMLHttp");}function getData(dataSource, divID){	if(XMLHttpRequestObject) {		var obj = document.getElementById(divID);		XMLHttpRequestObject.open("GET", dataSource);				XMLHttpRequestObject.onreadystatechange = function()		{			if (XMLHttpRequestObject.readyState == 4 && XMLHttpRequestObject.status == 200) {				obj.innerHTML = XMLHttpRequestObject.responseText;			}		}				XMLHttpRequestObject.send(null);	}}</script></head><body><table><tr><td><a id="note" href="javascript:getData('note.php?', 'note')" class="link">Note</a></td><td id="note"></td></tr></table>

please help me find what i missed........

Share this post


Link to post
Share on other sites

Just noticed, you have 2 id="note" references, when they should be unique within a page. But other than that i have have no problem calling function and retrieving content produced by note.php page.

 

try

<a href="javascript:void(null)" onclick="getData('note.php?', 'note')" class="link">Note</a>
Edited by dsonesuk

Share this post


Link to post
Share on other sites

Produce a link to file, or jsfiiddle it, it should and does work in IE11. Either that or you have saved it as ANSI instead of UTF-8 encoding.

Share this post


Link to post
Share on other sites

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.   Paste as plain text instead

  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.

Loading...

×
×
  • Create New...