Cannot call the JSON result in Jquery

前端 未结 1 329
囚心锁ツ
囚心锁ツ 2020-12-22 06:20

I have an action of the controller that return the result as the JSON result.(I test it ready, It works well with this action).

    public JsonResult GetProd         


        
相关标签:
1条回答
  • 2020-12-22 06:42

    you can use with $.ajax in jquery if your json format like this

    {"rows":[{"id":"1","username":"foo"},{"id":"2","username":"bar"}]}

                $.ajax({
                    url: urlProduct,
                    type:"GET",
                    success:function (data) {
                        $.each(data.rows,function(i,rows){
                          alert(rows.username);//will be show username foo and bar
    
                        });
                    }
                });
    

    this is the reference http://api.jquery.com/jQuery.ajax/

    and this is reference to json http://www.json.org/

    this is library can use for C# http://sourceforge.net/projects/csjson/

    0 讨论(0)
提交回复
热议问题