我们在做ajax 效果的时候,经常遇到类似的需求:从后台返回一个对象。一般是json格式的对象。 这时候需要将对象内容自动填充到页面中。
闲话少聊,下面是代码。
 
"-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
"http://www.w3.org/1999/xhtml">

"Content-Type" content="text/html; charset=utf-8" />
根据对象填充到对象的form中





"myform" method="get">

"50%" border="0">
    
        
        
        
    
    
    
        
    
          
    
    
    
        
        
    
    
        
        
    
    
        
        

    姓名:  

            "text" name="username" />

      书籍:    

      "checkbox" name="book" value="01"/>
            jquery
      "checkbox" name="book" value="02"/>
         java
      "checkbox" name="book" value="03"/>
         oracle    

      性别:    

      
          

    颜色:  
    
                     

    备注:  

    
              
"2">
            "button" name="padding" value="填充"/>
    







 
 
下面是效果图:就是将 js中创建的对象属性,填充到对应的控件中。
逻辑很简单。
将对象内容自动填充到form中_第1张图片