Javascript-und VERY-LONG-string

ich habe Probleme mit dem folgenden code:

function showTableData()
{
    var tableArray;
    var x = 0;
    var theHTML;

    for (i = 0; i < 7032; i++)
    {
        if (x = 0)
        {
            theHTML = '<tr>' + 
                '<th scope="row" class="spec">' + partNum[i] + '</th>' + 
                '<td>' + Msrp[i] + '</td>' + 
                '<td>' + blah[i] + '</td>' + 
                '<td>' + blahs[i] + '</td>' + 
            '</tr>' + theHTML;
            x++;
        }else{
            theHTML = '<tr>' + 
                '<th scope="row" class="specalt">' + partNum[i] + '</th>' + 
                '<td class="alt">' + Msrp[i] + '</td>' + 
                '<td class="alt">' + blah[i] + '</td>' + 
                '<td class="alt">' + blahs[i] + '</td>' + 
            '</tr>' + theHTML;
            x--;
        }
    }
    theHTML = '<table id="mytable" cellspacing="0">' + 
    '<tr>' + 
        '<th scope="col" abbr="Configurations" class="nobg">Part Number</th>' + 
        '<th scope="col" abbr="Dual 1.8">Msrp Price</th>' + 
        '<th scope="col" abbr="Dual 2">blahs Price</th>' + 
    '<th scope="col" abbr="Dual 2.5">Low Price</th>' + 
    '</tr>' + theHTML + '</table>';

    $('#example').append(theHTML);
}
 </script>

 <div id="example">
 </div>

Das problem ist, dass das $('#Beispiel').append(theHTML); nie ausgeführt wird (oder zeigt auf der Seite). Ich denke, es ist, weil der string ist soooooo lang! Es hat über 7000 Elemente im array, so dass im nicht sicher, ob das ist der Grund, oder wenn Ihr etwas anderes?

Jede Hilfe würde groß sein! Danke!

David

if (x=0) (Zeile 9) if (x==0) weiß nicht, ob das nur ein Tippfehler, obwohl
Sind Sie sicher, dass die Funktion aufgerufen wurde, richtig?
Einige Ratschläge. Erstellen Sie ein array mit push anstelle des string-Verkettung. Dann nutzen Sie array.join('') bevor Sie fügen Sie den html -. Bessere Leistung.
Danke, Hemlock. Behoben der Fehler.

InformationsquelleAutor StealthRT | 2011-01-09

Schreibe einen Kommentar