search

Home  >  Q&A  >  body text

javascript - Looking for an example of using ajax to request the display of complete points after getting the background interface.

Looking for an example of displaying data through jquery ajax request after getting the background interface. It is best to be complete and easy to understand. Thank you

淡淡烟草味淡淡烟草味2790 days ago422

reply all(2)I'll reply

  • 给我你的怀抱

    给我你的怀抱2017-05-19 10:31:04

    <script type="text/javascript">
        var url = "http://www.test.com/demo/test";
        $.ajax({
            type: "post",
            url: url,
            data: {
                "title": "dads", "name": "xxx", "sex": "1"
            },
            dataType: "json",
            success: function (data) {
                if ("true" == data.status) {
                    alert("成功!");
    
                    //这里也可以循环data里你要显示的数据
    
                    return true;
                } else {
                    alert("失败!错误信息如下:" + data.errorMsg);
                    return false;
                }
            },
            error: function (XMLHttpRequest, textStatus, errorThrown) {
                alert("请求失败!");
            }
        });
    
    </script>

    reply
    0
  • phpcn_u1582

    phpcn_u15822017-05-19 10:31:04

    $.post("api",{传递参数},function(data){
        console.log(data);
        //data就是返回来的数据
    })

    reply
    0
  • Cancelreply