2013-03-15 63 views
0
<input id="SubmitCommentsToInvoice" type="button" value="Comments" onclick="ShowCommentBox()" />  
    <script> 
       function ShowCommentBox() { 
        var obj =   
        { 
        "name":"Jim", 
        "Description":"Keep er lit", 
        "Price":"12.5" 
        }; 

        $("#WhereNameGoes").text(obj.name); 

        $("#dialog").dialog({ modal: true });    } 
     </script> 
<div id="dialog" title="Comments" style="display:none;"> 
     <table class="detailstable FadeOutOnEdit"> 
      <tr> 
       <th>Item</th> 
       <th>Description</th> 
       <th>Owed</th> 
      </tr> 
      <tr> 
       <td id="WhereNameGoes"></td> 
       <td id="Description"></td> 
       <td id="Price"></td> 
      </tr> 
     </table> 
     <br /> 
     </div> 

Tyring使用JSON在我的asp.net項目中傳遞字符串並在屏幕上顯示。 點擊評論btn時,只有'jim'出現在div中...爲什麼描述和價格不是?json傳遞多個字符串

Thaks

回答

2

因爲你沒有告訴它。所有你得到的是:

$("#WhereNameGoes").text(obj.name); 

你需要設置其他兩個相同的方式。