ajax如何输出json字符串中的一个对象?

ajax如何输出json字符串中的一个对象?
如图,我想在下面的标签中只显示11111而不是{"username":"11111"}。

img



```javascript
  <script type = "text/javascript">
$(document).ready(function(){
  $('#name1').keyup(function(){
    var a={};
    a.username = $('#name1').val();
    $.get('/hello',a,function(res){
      console.log(res);
      a=JSON.stringify(res)
      $('#info').text(a);
    });
  });
});
  script>

后端代码:

@app.route('/hello')  # 路由
def test_post():
    a=request.args
    return a


基本的数据取值都不清楚的话,真的建议好好看看文档了

$('#info').text(res.username);

对象 的话 对象.key就能输出了 res.username

你把这个粘贴上去试试

    <script type = "text/javascript">
  $(document).ready(function(){
    $('#name1').keyup(function(){
      var a={};
      a.username = $('#name1').val();
      $.get('/hello',a,function(res){
        $('#info').text(res.username);
      });
    });
  });
    </script>