0

これが私のJson応答形式です:-

{"Value":[{"ID":"1","productID":"10","subsID":"9","MinPrice":"500","MaxPrice":"50000","Subs":"xyz100"}]}

これが私の.jsコードです:-

function productURL(url) {
    alert(url);
    $.ajax({
        url: url,
        type : "GET",
        dataType : "json",
        contentType: "application/json",
        async : false,
        success : function(msg) {
            var respPrice = msg.Value;
            $.each(respPrice, function(index, value) {
                if(value.VarietyID == 0) {
                    alert('No product subs list found');
                } else {

                    subsId = value.subsID;
                    substance = value.subs;
                    minPrice = value.MinPrice;
                    maxPrice = value.MaxPrice;
                    respPrice += '<li class="ui-btn ui-btn-icon-right ui-li-has-arrow ui-li ui-last-child ui-btn-up-e">' + substance + minPrice + '-' + maxPrice + '</li>';
                    };

                    }           
                });
             $('#productList').append(respPrice).listview('refresh');

                },
            error : function(e) {
                console.log(e.message);
                alert('Error Occoured');
            }
        });
}

listview を適切に生成するには、どのような変更を行う必要がありますか? どんな助けでも大いに感謝します。

4

2 に答える 2

1

なぜあなたはこのようにしないのですか??

$.each(respPrice.Value, function(index, value) {
      if(respPrice.VarietyID == 0) {
         alert('No product subs list found');
      } else {

       subsId = value.subsID;
       substance = value.Subs;
       minPrice = value.MinPrice;
       maxPrice = value.MaxPrice;       
       $respPrice = '<li class="ui-btn ui-btn-icon-right ui-li-has-arrow ui-li ui-last-child ui-btn-up-e">' + substance + minPrice + '-' + maxPrice + '</li>';

       // append here
       $('#productList').append($respPrice);
     }               
 });

 // and when all done, after $.each() refresh the listview
 $('#productList').listview('refresh');

ここにフィドルがあります:http://jsfiddle.net/REthD/19/

于 2013-09-04T05:48:42.133 に答える
0

変化する

success : function(msg) {
            var respPrice = "";
            $.each(respPrice, function(index, value) {
                if(value.VarietyID == 0) {
                    alert('No product subs list found');
                } else {

                    subsId = value.subsID;
                    substance = value.subs;
                    minPrice = value.MinPrice;
                    maxPrice = value.MaxPrice;
                    respPrice += '<li class="ui-btn ui-btn-icon-right ui-li-has-arrow ui-li ui-last-child ui-btn-up-e">' + substance + minPrice + '-' + maxPrice + '</li>';
                    }

                    } 
 $('#productList').append(respPrice).listview('refresh');          
                });


                },
            error : function(e) {
                console.log(e.message);
                alert('Error Occoured');
            }
        });
于 2013-09-04T05:44:25.360 に答える