开发者

Return values are not rendering correctly

When I want to render return values into a html listbox , the values are splitted after each character.

This is the jQuery code:

   $.get('GetBusiness.aspx', { Businessnr: Dossierno }, function (returndata) {
     // for each address in returndata
     $.each(returndata, function (val, text) {
        // add an option tag to the listbox id test
        $("#test").append(
           $("<option>&l开发者_如何学Pythont;/option>").val(val).html(text)
        );
   });

My listbox does this:

i
t

r
e
n
d
e
r

What do I wrong ?


You're iterating over an string:

>>> jQuery.each("hello", function(val, text) { console.log(val,text); });
0 h
1 e
2 l
3 l
4 o

Make sure what kind of data you expect to receive from GetBusiness.aspx. You can always check using console.log.

Good luck!


try to put $.getJSON instead of $.get

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜