Jump to content

Episode 1x05 shownotes missing


Recommended Posts

i unfortunately don't have the code. i can go through the episode and try and get it myself if you'd like? make sure though you are using a webserver for this, not just running it off a local file. you must be running it through apache or something.

Link to post
Share on other sites
i unfortunately don't have the code. i can go through the episode and try and get it myself if you'd like? make sure though you are using a webserver for this, not just running it off a local file. you must be running it through apache or something.

yeah, I have run it with wamp, with no good results. I really wouldn't like to get you in the trouble of doing that just for me, thax for your help anyway.

Link to post
Share on other sites

well, being obsessive like i am, i wanted to see if it did work, so i wrote it out and chucked it on my apache server and it worked fine for me.

Sample1.xml

<?xml version="1.0" encoding="iso-8859-1"?>

<root>

No

</root>

index.html

<html>

<head>

<title>Ajax Testing</title>

</head>

<script language="javascript">



    //Set default http_request to false for initiation

    var http_request = false;



    function request(url)

    {

        http_request = false;

        

        // Mozilla, Safari, Opera and all other browsers use this request

        if (window.XMLHttpRequest)

        {

            http_request = new XMLHttpRequest();

            /*

            NOTE:

                Some versions of the mozilla browsers won't work if the response from the **Missing comment**

                In order to fix this, we can use an extra function to override the header **missin comment**

            */

            if (http_request.overrideMimeType)

            {

                http_request.overrideMimeType('text/xml');

            }

        }//Only IE uses this, NOTE: Active X Object

        else if (window.ActiveXObject)

        {

            try

            {

                http_request = new ActiveXObject("Msxml2.XMLHTTP");

            }

            catch (e)

            {

                try

                {

                    http_request = new ActiveXObject("Microsoft.XMLHTTP");

                }

                catch (e) {}

            }

        }

        //if still false, then XMLHTTP instance is not created

        if (!http_request)

        {

            alert('Cannot create an XMLHTTP instance');

            return false;

        }



        http_request.onreadystatechange = readyState;

        http_request.open('GET', url, true);

        http_request.send(null);

    }



    function readyState()

    {

        //Displaying all http_request.readyState

        if(http_request.readyState == 1)

        {

            alert("1 (loading)");

        }

        if(http_request.readyState == 2)

        {

            alert("2 (loaded)");

        }

        if(http_request.readyState == 3)

        {

            alert("3 (interactive)");

        }

        if(http_request.readyState == 4)

        {

            if (http_request.status == 200)

            {

                var xmldoc = http_request.responseXML;

                var root_node = xmldoc.getElementsByTagName('root').item(0);

                alert(root_node.firstChild.data);

            }

            else

            {

                alert('Error with request');

            }

        }

    }

</script>

<body>

<table width="200" border="0" align="center">

<tr><td>

<span style="text-decoration: underline" onClick="request('sample1.xml')">Request XML</span>

</td></tr>

</table>

</body>

</html>

try out that, if it doesn't work it's either your web server or your browser. it works for me with apache and firefox. now, to register and chuck it on the wiki!

Link to post
Share on other sites
well, being obsessive like i am, i wanted to see if it did work, so i wrote it out and chucked it on my apache server and it worked fine for me.

try out that, if it doesn't work it's either your web server or your browser. it works for me with apache and firefox. now, to register and chuck it on the wiki!

thank you so much, now at least I get the javascript alert messages, but I get alert number 1 repeated and on alert number 4 it gives me the exception "Error with request". ¿Could it be something with WAMP?

Edit: I uploaded it into a real server and it throws me this error using IE:

Line: 76

Char: 13

Error: Object required

Code: 0

Link to post
Share on other sites

possibly. what browser are you using?

from that code, i don't think there is anything special required on the webserver side. but then again, i'm not a web programmer. i would think it is the browser, i know a lot of browsers don't support ajax.

Link to post
Share on other sites
possibly. what browser are you using?

from that code, i don't think there is anything special required on the webserver side. but then again, i'm not a web programmer. i would think it is the browser, i know a lot of browsers don't support ajax.

Can't be the browser, I've tried it both with firefox and IE. Can't be the server either. Are you sure it gives you the 4 alert messages each with different text??

Link to post
Share on other sites

ok, based upon the info you chucked in the edit it's definately the browser. i may have copied it down wrong, your browser security may be too strong or maybe it's just a newer version of IE that isn't entirely backwards compatible (as i said, i'm not a web programmer so i don't know what has changed in IE since the episode was made). hopefully someone here can help you, but in the mean time i suggest google to find some other ajax examples and see how they handle IE.

hth.

Link to post
Share on other sites

yeah mate, positive. except "1" is repeated for some reason. maybe it is the webserver then? i just tried IE 6 and it works fine for me too. i'm running apache on linux. and tried firefox on both linux and windows.

**edit**

btw, just to point something out, jon DOES specifically mention apache in the episode, so maybe it's possible there is something different between your webserver? having a different request status. try removing that if statement and the entire else block and just try and force it to run the true section, see if that works.

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.

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...