function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
MimiranMimiran 

Errata: Bug in "Hello World" AJAX guide

There are some minor bugs in the "Hello World" example in the "AJAX Getting Started - Part 1 Guide", linked from the AJAX Beta3 page:  http://blog.sforce.com/sforce/2006/04/ajax_toolkit_be.html .  The bugs are minor and don't affect the normal output, but since it's a Hello World app it'll be used as a reference. (I actually found the bug when trying to use this as a reference.)

Here is the meat of the Hello World example at the bottom of Part 1 of the guide.  My changes are in red.  The first part creates a textNode variable but doesn't use it (that line is useless and should be deleted), while the second part creates a variable and wants to use it but doesn't (the text node needs to be added to the document).


                   if (queryResult.size > 0) {
                       
var
output = "";
                       
for
(var i=0;i<queryResult.records.length;i++) {
                           
var
dynaBean = queryResult.records[i];
                           
output += dynaBean.get(
"Id") + " " + dynaBean.get("name") + " [Industry - " + dynaBean.get("Industry") + "]<br>";
                       
}

                        // this line is useless, so take it out
                        //
var
textNode = document.createTextNode(output);
                       
document.getElementById(
"output").innerHTML = output;
                   
} else {

                       
var
textNode = document.createTextNode("No records matched.");
                         // this textNode needs to be added to the document to get displayed:
                        document.getElementById("output").appendChild(textNode);
                    }

The_FoxThe_Fox
Hello,

Yes but no because innerHTML is a microsoftism (indeed recognised by browser based on gecko) but it not perfect. so we create DOM node

So...
Regards
MimiranMimiran
Oh, that's another bug then. ;)  I only made changes to the text in red.  The changes I made are....

1) Commenting out a line which doesn't do anything.
2) Adding a line so the second message actually gets displayed.

It displays the messages in two different ways (one via innerHTML, and one via DOM node) which is inconsistent but that's a minor detail.  Unfortunately, both ways it displays the text are wrong (the first one shows up but has extra code that doesn't do anything, the second way won't even show up).