0

I have following code that is supposed to display product details when clicked on. The data is correctly obtained from the database and i out in alert before invoking the jquery ui dialog and it had the right data.

$("body").append('<div id="popup"></div>');

document.getElementById('popup').innerHTML  = "jk;hcjaskda;ldA;LSDMAKDOIDM;A,MCSCM;lc"sac<'LC;MClmca,.c sm,vnkdc ADVdL:VadMVa;dvadvNsmv S/MV s/vn,Va.<VMA:dvma:DVMa<dv d><v a><d S,CVNDMVaA>VM:LDvm;LVMM,CVMAdv<?.vdm;LDVdvDVadvDVDVVVVVVVVVVVVVVVVVVVVVVVVsvdSV/m,vn,m vmn.,c x V/,.ADMNV/ma,.vm./,vm.,vm,DVkldjfk'ejfwejfqlekfmF;LQEJFQ.L,DK;LKKKKKKKKKKKKKKKKKKKKKKKKKKKKK'LWKF;PWOJVMWPOV";
$( '#popup').dialog({
    modal: true,
    autoOpen: true,
    width:500,
    height:500,
    buttons: {
        "Back": function() {
            $('#popup').html('');
            $('#popup').dialog('close');
        }

    }

});

The pop up only shows 160 charecters jk;hcjaskda;ldA;LSDMAKDOIDM;A,MCSCM;lc"sac<'LC;MClmca,.c sm,vnkdc ADVdL:VadMVa;dvadvNsmv S/MV s/vn,Va.<VMA:dvma:DVMa<dv d><v a><d S,CVNDMVaA>VM:LDvm;LVMM,CVMAdv

is what is displayed. NOt sure where it is getting truncated. The dialog only shows a H scroll bar

user1361914
  • 411
  • 1
  • 14
  • 26
  • Most likely the browser sees and tries to create an element. – Kevin B Aug 20 '13 at 15:48
  • is this code included in a php file? – MaveRick Aug 20 '13 at 15:49
  • use $('#popup').text('Your text string') instead for starters. If you're going to use jquery you might as well use it. – Rooster Aug 20 '13 at 15:49
  • I would suggest that you escape any characters that would break our JavaScript code. – Tim B James Aug 20 '13 at 15:50
  • Well.. It truncates at `` which could be getting interpreted by php as a code block. But regardless of whether this is the javascript or your php file, you should be getting syntax errors and it shouldn't work at all.. – Jason P Aug 20 '13 at 15:50

1 Answers1

0
  • .innerHTML doesn't have a limitation.
  • In your example you have to escape the string before setting it!, your script contains many chars that causing syntax errors like " and it has the tag <? as well which is a php or other server side language opening tag.

you can escape these chars using this up to this table: entity-escape-characters-table

BTW: This question is a dublicate of innerhtml-size-limit

Community
  • 1
  • 1
MaveRick
  • 1,181
  • 6
  • 20
  • `innerHTML` does have a browser specific size limit, I've tested, see http://stackoverflow.com/a/27545633/694469 – KajMagnus Dec 18 '14 at 11:43
  • I updated my answer — seems there's no limit, but the contents gets split into many `childNoeds[*]` each one limited to 65536 chars. – KajMagnus Dec 18 '14 at 12:08