DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

+ Reply to Thread
Results 1 to 3 of 3
  1. #1
    Join Date
    Mar 2004
    Posts
    9

    Ajax Simple Question - Please Help -- Very Frustrated

    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>
    Last edited by quantass; 03-26-2010 at 06:55 PM.

  2. #2
    Join Date
    Apr 2007
    Location
    Sterling Heights, Michigan
    Posts
    8,651
    Moved To The Ajax Section

    What errors are you getting?
    I don't answer coding questions via PM or Email. Please post a thread in the appropriate forum section.
    Please use [Code]your code goes in here[/Code] tags when posting code.
    Before posting your question, did you look here?
    Got a question on Linux? Visit our Linux sister site.
    Modifications Required For VB6 Apps To Work On Vista

  3. #3
    Join Date
    Jan 2010
    Posts
    1
    ajax does not work cross domains... If it does, I do not know how it does, I have never been able to get it to work, I have heard it does not work across domains though. maybe I heard wrong, but like I said, never been able to get it to work myself...

Similar Threads

  1. Very Simple Question - I think
    By Andrew Murphy in forum VB Classic
    Replies: 1
    Last Post: 09-03-2002, 01:17 AM
  2. Simple Java DOM question
    By Lenin in forum XML
    Replies: 0
    Last Post: 03-21-2001, 04:01 PM
  3. Simple Threading question
    By R in forum Java
    Replies: 0
    Last Post: 11-04-2000, 02:57 AM
  4. Simple Data Environment Question
    By Alex Nitulescu in forum VB Classic
    Replies: 1
    Last Post: 10-21-2000, 05:13 AM
  5. Simple Class Variables question
    By Gary McCallum in forum Java
    Replies: 2
    Last Post: 10-20-2000, 11:20 AM

Bookmarks

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


Top DevX Stories

Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL


Sponsored Links