Thursday, April 14, 2011

Delimitter for string value for Ajax response

I have a javascript function which would populate a list of related item in a div when the user types a letter in the ipyt box.I m calling a aspx (C# -codebehind page) page in my ajax call and that aspx page would return the output as a string delimitted by | (pipe symbol) .But my code is breaking if the item of string contains a | symbol in itself. for Normal condition, My items are Item1, Item2,Item 3 ajax server page will output this as Item1|Item2|Item3 and iside my javascript i am spliting this string with | and getting each value. If the Item contains a pipe symbol Ex : Ite|m1 The script of splitting is braking.Can anyone tell me how to solve this.Is there any character which is not present in keyboeard , which i cam make use of for the delimiter

Thanks in advance

From stackoverflow
  • I think you should try using JSON ( homepage / wikipedia ) instead of concatening / splitting.

  • In the past I've used ~ and | 's and then ignored those keypress events but I agree with andi - json is a better approach

0 comments:

Post a Comment

Note: Only a member of this blog may post a comment.