SitePoint Sponsor

User Tag List

Page 1 of 2 12 LastLast
Results 1 to 25 of 27
  1. #1
    ********* Articles ArticleBot's Avatar
    Join Date
    Apr 2001
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Article Discussion

    This is an article discussion thread for discussing the SitePoint article, "Build Your Own AJAX Web Applications"

  2. #2
    SitePoint Guru
    Join Date
    Nov 2005
    Location
    Midwest
    Posts
    777
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    This was a great article and I will defintely refer to it in the future.

  3. #3
    SitePoint Enthusiast
    Join Date
    Jun 2006
    Posts
    61
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I almost fell asleep half way through page 2 because it's so boring. Who cares about the loss of scope or error handlers or aborting requests or whatever BEFORE you have written even a single page that works? You even write that setting the correct content type probably won't be "suitable for use in your applications today", so why on earth bore the user with it before he had a single feeling of success?

    Would it have been so difficult to give the user only the very basics, then give him a small script right away with which he can feel that he accomplished something and THEN explain how it works? After that you can still tell him about aborting requests and the like.

    This is a good example for a book written by a geek who has lost touch with reality.

  4. #4
    Pixelbox
    SitePoint Community Guest
    The author tried to go step by step throught he breakdown of the Ajax class script he wrote, but I found it very confusing to drop various code blocks in different places. I recommend either A) provide a complete working ajax.js in full (either displayed or for download) so the begginer can compare their script with yours, or B) don't jump around and explain your code line-by-line, in order.

    I've tried the example, and it is not working. I KNOW it is because I did something wrong, but is that really MY fault or the AUTHOR's?

  5. #5
    Kiwi Fr00t jylyn's Avatar
    Join Date
    Apr 2005
    Location
    New Zealand
    Posts
    218
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Aren't there *two* 'A's in 'AJAX'? :-)

  6. #6
    Steve Lawrence
    SitePoint Community Guest
    I have to agree with the first two comments. I got halfway through this and gave up because I knew the chance of getting this script up and running as a first ever AJAX page were practically nil.

  7. #7
    SitePoint Member
    Join Date
    Nov 2002
    Posts
    9
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Wink

    I agree partially with a first comment. (I bought a book and I'm reading it now with a great pleasure!) It would be nice to have here a "summary" code built from all these well-described parts. It would be nice to start or to finish each chapter in a book with a complete code built in this chapter.
    At the same time after you buy a book you can download a complete application code. It helps.
    And I must say, it's a wonderful book, if you're practical developer you will immediately feel by numerous small details that author has real experience; a code style is excellent. Yes, I found couple of typos, but it may be a good exercise to fix them, if you understand what you're reading.

  8. #8
    SitePoint Member
    Join Date
    Nov 2002
    Posts
    9
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Unhappy

    Quote Originally Posted by Arne Thönes
    Who cares about the loss of scope or error handlers or aborting requests or whatever BEFORE you have written even a single page that works? You even write that setting the correct content type probably won't be "suitable for use in your applications today", so why on earth bore the user with it before he had a single feeling of success?
    I strongly disagree. A responsible programmer DOES care about loss of scope, error handlers, aborting requests and a myriad of other details. It's too often when I spend time fixing these small things in someone else code because that programmer didn't care to write a stable code! And with complicated asynchronous nature of AJAX it's probably even more important, otherwise code will become unmanageable soon.
    Last edited by Vladimir Kelman; Jul 4, 2006 at 22:57.

  9. #9
    SitePoint Member
    Join Date
    Nov 2002
    Posts
    9
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    A code correction: in "Singletons with JavaScript" topic (chapter 3)

    Code:
    var onTimeout = function() {
            var self = ScopeTest();
            alert(self.message);
          };
    It should be
    Code:
    var onTimeout = function() {
            var self = ScopeTest;
            alert(self.message);
          };
    It's not a ScopeTest function call, it is a "pointer to object" variable assignment.
    Last edited by Vladimir Kelman; Jul 4, 2006 at 22:56.

  10. #10
    SitePoint Member craiga's Avatar
    Join Date
    Apr 2005
    Location
    Melbourne, Australia
    Posts
    9
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Vladimir Kelman
    A code correction: in "Singletons with JavaScript" topic (chapter 3)

    ...

    It's not a ScopeTest function call, it is a "pointer to function" variable assignment.
    Thanks for highlighting that. I've made a note of this error, and I'll add it to the book's corrections and typos page and make sure it's fixed for subsequent reprints of the book. If you spot any more errors, please, let us know.
    Craig Anderson
    Web Developer, SitePoint Solutions

  11. #11
    SitePoint Member
    Join Date
    Nov 2002
    Posts
    9
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by craiga
    If you spot any more errors, please, let us know.
    There were two tiny things which I already reported there. I wasn't sure, however, what "Reason for Contact" to choose there. Should it be "Report Bugs or Problems with the Site"? It's not clear.

    Tiny things were:
    In chapter 2 in ''Example: a Simple Test Page" in "Example 2.18. ajaxtest.html (excerpt)" (a top of the page 31 in book) doGet() call should look like
    Code:
    ajax.doGet('/fakeserver.php', hand, 'xml');
    rather than
    Code:
    ajax.doGet('/fakeserver.php', hand);
    because doGet() has a default value 'text' for a third parameter and we want it to be 'xml' in this case.
    Also, just below that example a phrase
    You would want to make absolutely sure in this case that somepage.php was really serving valid XML
    would better be
    You would want to make absolutely sure in this case that fakeserver.php was really serving valid XML
    .

  12. #12
    SitePoint Enthusiast
    Join Date
    Jun 2006
    Posts
    61
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Vladimir Kelman
    I strongly disagree. A responsible programmer DOES care about loss of scope, error handlers, aborting requests and a myriad of other details. It's too often when I spend time fixing these small things in someone else code because that programmer didn't care to write a stable code! And with complicated asynchronous nature of AJAX it's probably even more important, otherwise code will become unmanageable soon.
    Please point out to me where I said that the author shouldn't have included these parts at all. Oh wait, you can't. Too bad.
    I said that the author should give the reader some working code first with as little as possible explanations, so a beginner has a feeling of success first. THEN the author could have explained it in detail with all the other points he made.
    The way it is now I almost fell asleep before I wrote a single line of code.

  13. #13
    SitePoint Member
    Join Date
    Nov 2002
    Posts
    9
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Arne, there are different approaches and there are different readers too. Personally I like author's piece-by-piece with attention to details style. Yes, there might be the complete code presented at the beginning of each chapter or so, but it could be to hard to read without understanding of how each part works and what it serves for. I think that because of complex and mutually dependent nature of AJAX it's hard to understand those application in one big piece. After all, there is a downloadable code where one can look at everything together.
    Anyway, reading this book forced me to take Flanagan's volume again - to clarify some forgotten JavaScript concepts. Flanagan's book is quite different: academic, concise, crystal clear, and just outstanding. I cannot wait for the next edition to come...
    Last edited by Vladimir Kelman; Jul 9, 2006 at 10:48.
    --
    Vladimir Kelman
    http://www.vkelman.com

  14. #14
    SitePoint Enthusiast
    Join Date
    Jun 2006
    Posts
    61
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    And my opinion is that he should have done it differently to better accomodate beginners. If you disagree, great. I for one wouldn't have cared if he had presented me with some code that I didn't understand the specifics of at first. I would have been happy if I had some feelings of success first before actually understanding it. Especially that part about the content type where he himself admits that it's superfluous gets on my nerves.
    I'm glad I read through this article before I paid for the book.

  15. #15
    SitePoint Member
    Join Date
    Dec 2005
    Posts
    9
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    ajaxtest.html ?

    All the code should be downloaded, and I did, but I can not find ajaxtest.html
    Do I have to type it my self what is on page 31 and 32 and save it as ajaxtest.html

    Is it anything more missing in the downloaded code?

  16. #16
    SitePoint Member
    Join Date
    Nov 2002
    Posts
    9
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I can not find ajaxtest.html
    sm2aye, you don't need ajaxtest.html: it's just a side example and is not used in main application.
    --
    Vladimir Kelman
    http://www.vkelman.com

  17. #17
    SitePoint Member
    Join Date
    Dec 2005
    Posts
    9
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for info Vladimir!
    Well I thought when they print ajaxtest.html (excerpt) it was a file that did exist!
    OK thanks again Vladimir

  18. #18
    SitePoint Member
    Join Date
    Nov 2002
    Posts
    9
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I think you're right
    --
    Vladimir Kelman
    http://www.vkelman.com

  19. #19
    SitePoint Member
    Join Date
    Dec 2005
    Posts
    9
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    One Forum for each book?

    I got most books from SitePoint now!
    What I am looking for is one Forum for one certain book.

    So where to find the Forum for "Build Yor Own AJAX WEB APPLICATIONS" ?

  20. #20
    SitePoint Wizard silver trophy Bleys's Avatar
    Join Date
    Feb 2003
    Location
    RI-USA
    Posts
    5,620
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by sm2aye
    I got most books from SitePoint now!
    What I am looking for is one Forum for one certain book.

    So where to find the Forum for "Build Yor Own AJAX WEB APPLICATIONS" ?
    The forums and the books are separate entities. Just post your questions in the forum that best matches the subject of the question (i.e., a question about Javascript would go in the Javascript forum, about XML in the XML forum, etc.).

    For specific support related to an order or to report a bug or issue with a book, use the SitePoint Support and Feedback forum.
    Josh is a ghost
    rails & work & twitter

    Organization is the
    death of creativity.

  21. #21
    SitePoint Member
    Join Date
    Dec 2005
    Posts
    9
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks Josh!
    I was afraid to have that answer.. I thought one forum for each book was the best choice.
    One book can cover PHP, HTML and CSS and it will be hard for me to jump between all forums when I like to talk about one single book.

    Ok I have to do what You informed me about then!
    Thanks!

  22. #22
    SitePoint Member
    Join Date
    Dec 2005
    Posts
    9
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    ajaxtest.html

    This is the script I made from the book, page 30

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Script//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <title>A Simple AJAX Test</title>
    <script type="text/javascript" src="ajax.js"></script>
    <script type="text/javascript">
    var hand = function(str) {
    alert(str);
    }
    var ajax = new Ajax();
    ajax.doGet('fakeserver.php', hand);
    </script>
    </head>

    <body>

    </body>
    </html>

    If I typed like the book told me:
    ajax.doGet('/fakeserver.php', hand);
    Then I did get an error saying:
    Not Found
    The requested URL /fakeserver.php was not found on this server.


    So I wonder what this "/" was doing?

  23. #23
    SitePoint Zealot
    Join Date
    Jul 2006
    Posts
    116
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'm glad that I read it because it got me to want to learn AJAX. But I must admit that I learned nothing from that tutorial. Sure it give you the code to make a nice web aplication, but it teaches you next to nothing. I found a good tutorial from IBM. Unfortunatly, only the first three chapters "really" deal with AJAX, the other two just talk about the DOM, which I already knew, so they were a waste of time.

  24. #24
    ryan
    SitePoint Community Guest
    Help please, I've tried running the js script over and over replacing variables after variables but it still won't run. i've placed alerts everywhere and it seemed to die at self.req.onreadystate
    can somebody please help me with the code ?

    function Ajax() {
    this.req = null;
    this.url = null;
    this.method = 'GET';
    this.async = true;
    this.status = null;
    this.statusText = '';
    this.postData = null;
    this.readyState = null;
    this.responseText = null;
    this.responseXML = null;
    this.handleResp = null;
    this.responseFormat = 'text', // 'text', 'xml', or 'object'
    this.mimeType = null;

    // set init as a function
    // purpose : to create a new XMLHttpRequest to run AJAX in different
    // browsers, ActiveXObject is used for IE
    this.init = function() {
    if (!this.req) {
    try {
    // Try to create object for Firefox, Safari, IE7, etc.
    this.req = new XMLHttpRequest();
    }
    catch (e) {
    try {
    // Try to create object for later versions of IE.
    this.req = new ActiveXObject('MSXML2.XMLHTTP');
    }
    catch (e) {
    try {
    // Try to create object for early versions of IE.
    this.req = new ActiveXObject('Microsoft.XMLHTTP');
    }
    catch (e) {
    // Could not create an XMLHttpRequest object.
    return false;
    }
    }
    }
    }
    return this.req;
    };

    // doGet function
    // purpose : to create a GET
    this.doGet = function(url, hand, format) {
    this.url = url;
    this.handleResp = hand;
    this.responseFormat = format || 'text';
    this.doReq();
    };

    // doReq function
    // purpose : to create a request to AJAX engine
    this.doReq = function() {
    if (!this.init()) {
    alert('Could not create XMLHttpRequest object.');
    return;
    }

    if (this.mimeType) {
    try {
    req.overrideMimeType(this.mimeType);
    }
    catch (e) {
    // couldn't override MIME type -- IE6 or Opera?
    }
    }
    this.req.open('GET', '/fakeserver.php', true);

    var self = this; // Fix loss-of-scope in inner function
    self.req.onreadystatechange = function() {
    var resp = self.req.responseText;
    if (self.req.readyState == 4) {
    switch (self.req.responseFormat) {
    case 'text':
    resp = self.req.responseText;
    break;
    case 'xml':
    resp = self.req.responseXML;
    break;
    case 'object':
    resp = req;
    break;
    }
    if (self.req.status >= 200 && self.req.status <= 299) {
    this.handleResp(resp);
    }
    else {
    self.handleErr(resp);
    }
    }
    } // end function declaration for req.onreadystatechange


    }; //end function declaration for doReq


    this.handleErr = function() {
    var errorWin;
    try {
    errorWin = window.open('', 'errorWin');
    errorWin.document.body.innerHTML = this.responseText;
    }
    catch (e) {
    alert('An error occurred, but the error message cannot be '
    + 'displayed. This is probably because of your browser\'s '
    + 'pop-up blocker.\n'
    + 'Please allow pop-ups from this web site if you want to '
    + 'see the full error messages.\n'
    + '\n'
    + 'Status Code: ' + this.req.status + '\n'
    + 'Status Description: ' + this.req.statusText);
    }
    };

    // abort function
    // destroy request made to AJAX engine
    this.abort = function() {
    if (this.req) {
    this.req.onreadystatechange = function() { };
    this.req.abort();
    this.req = null;
    }
    };


    this.setMimeType = function(mimeType) {
    this.mimeType = mimeType;
    };

    };

  25. #25
    SitePoint Addict telos's Avatar
    Join Date
    Mar 2005
    Location
    192.168.2.34
    Posts
    279
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    When using doPost instead of doGet, the dataPayload variable should have a value of something like this: "data=this is data".

    Example: newAjax.doPost('yourPage.php', "data=this is data", someFunction);

    Also, here is a good reference: http://www.w3schools.com/XML/xml_http.asp - since many things in this tutorial are unclear.


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
  •