When I get list items from a custom list it returns undefined on the top and after other list items. How to fix this problem?

enter image description here

my code:

enter image description here

  • 1
    Well without your code it is hard to tell what you are doing wrong.. Sep 4 '15 at 9:00
  • hi. I added code now
    – Gio
    Sep 4 '15 at 9:11
  • 2
    I guess the title of the 1st listitem is empty?
    – Akhoy
    Sep 4 '15 at 9:18
  • FYI, I see the getQueryStringParameter function (used in so many bloated examples). Microsoft gives you JSRequest for free in SharePoint. Sep 4 '15 at 9:35
  • As for adding your code... paste your code in a texteditor.. indent all with one Tab (at least 4 spaces), then paste it in StackOverflow Sep 4 '15 at 9:37

It is due to un-initialized variable lstString
In onS() function, initialize the string variable by replacing var lstString; with var lstString = ""

  • 1
    Spot on, the undefined text is from the first time the variable is concated with += when it is not yet "typed" as a string in javascript Sep 4 '15 at 10:46
  • +1 Nice catch :)
    – Akhoy
    Sep 4 '15 at 10:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.