dcsimg


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: Ajax Help?

  1. #1
    Join Date
    Jun 2007
    Posts
    2

    Ajax Help?

    I'm having a problem with an ajax script, its working in IE (sort of) and not in Firefox.

    http://www.willisemail.co.uk/brk/

    The script basically brings up a news item when one of the picture links is clicked.

    In IE the news item is displayed then dispears and in Firefox nothing.

    Any help would be really helpful.

    Thanks

    Jemes

    Code:
    var xmlHttp
    
    function showHint(str){
    
    alert(str)
    
    if (str.length==0)
      { 
      document.getElementById("txtHint").innerHTML="";
      return;
      }
    
    xmlHttp=GetXmlHttpObject()
    if (xmlHttp==null)
      {
      alert ("Your browser does not support AJAX!");
      return;
      } 
    
    var url="hint.asp";
    url=url+"?ID="+str;
    url=url+"&sid="+Math.random();
    xmlHttp.onreadystatechange=stateChanged;
    xmlHttp.open("GET",url,true);
    xmlHttp.send(null);
    } 
    
    
    function stateChanged() 
    { 
    if (xmlHttp.readyState==4){ 
    document.getElementById("txtHint").innerHTML=xmlHttp.responseText;}
    alert(document.getElementById('txtHint').innerHTML=xmlHttp.responseText)
    }
    
    
    function GetXmlHttpObject()
    {
    var xmlHttp=null;
    try
      {
      // Firefox, Opera 8.0+, Safari
      xmlHttp=new XMLHttpRequest();
      }
    catch (e)
      {
      // Internet Explorer
      try
        {
        xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
        }
      catch (e)
        {
        xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
        }
      }
    return xmlHttp;
    }

    Code:
    <span id="txtHint"></span>
    Code:
    <a href="" onclick="showHint(<%=rsNews("ID")%>)"><img src="uploads/news_images/<%=rsNews("img")%>" alt="<%=left(rsNews("caption"),150)%>" align="top" class="news_Left2" /><%=Left(rsNews("headline"),55)%></a>

  2. #2
    Join Date
    Jun 2007
    Posts
    2
    Solved the problem.

    It was all to do with my trigger calling the ajax script all I needed was the # in the href and it woks fine.

    Code:
    <a href="#" onClick="showHint(<%=rsNews("ID")%>)"><img src="/uploads/news_images/<%=rsNews("img")%>" alt="<%=left(rsNews("caption"),150)%>" align="top" class="news_Left2" /><%=Left(rsNews("headline"),55)%></a>
    The folowing link helped.

    http://www.matthom.com/archive/2006/...ary-ajax-error

Similar Threads

  1. Ajax within Ajax generated code
    By geekdesign in forum AJAX
    Replies: 2
    Last Post: 09-16-2007, 08:38 PM
  2. A new AJAX IDE !
    By ajaxtoday in forum AJAX
    Replies: 3
    Last Post: 04-11-2007, 01:40 AM
  3. Ajax: Working in IE but not Mozilla?
    By MarkMac in forum AJAX
    Replies: 0
    Last Post: 03-15-2007, 04:41 AM
  4. Basic AJAX examples
    By Frefaln in forum AJAX
    Replies: 2
    Last Post: 06-03-2006, 07:45 PM
  5. New forum + some AJAX links
    By Lori in forum AJAX
    Replies: 0
    Last Post: 02-09-2006, 02:26 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center