jquery的常用方法有哪些


当前第2页 返回上一页

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

<script>

    //把所有需要用到的地址归类到一个对象里

    var webUrl = {

        "show1Url": "{{ url('address/list1') }}",

        "show2Url": "{{ url('address/list2') }}",

        "show3Url": "{{ url('address/list3') }}"

    };

 

    // get方式

    function getData() {

        $.get(webUrl.show1Url,  //获取地址

            function(json){

                console.log(json);

             });

    }

 

    // post方式

    function postData(v1) {

        $.ajaxSettings.async = true;   //在这里设置同步或异步 默认为true(可不写)  false为同步

 

        $.post(webUrl.show2Url,   //获取地址

            {

                "id":v1          //需要传输的数据

            },

            function(json){

                console.log(json);

            });

    }

 

    // ajax方式

    function fullData(id) {

        $.ajax({              //  AJAX 请求设置。所有选项都是可选的。

            async:false,        //请求是同步或异步    默认为true  为true时不用写

            type: "POST",            //设置类型

            url: webUrl.show3Url,           //数据传输地址

            dataType: "json",               //获取的数据类型

            data: {"id":id},            //传参

            success: function (json) {      //请求成功之后调用

                // console.log(json);

                console.log(json);

            },

            error: function () {        //请求出错时调用

                console.log("请求失败");

            }

        })

    }

 

</script>

以上就是jquery的常用方法有哪些的详细内容,更多文章请关注木庄网络博客

返回前面的内容

相关阅读 >>

jQuery怎么判断节点是否存在?

jQuery 怎么让a不跳转

jQuery有克隆方法吗?

jQuery 如何判断iframe是否加载完成

jQuery如何用this选择子元素

jQuery如何判断滚动条是否到底部

jQuery中$符号的作用是什么?

jQuery怎么判断字符串是否包含子串

jQuery内容过滤选择器有哪些

浅谈jQuery多库冲突问题的几种解决方法

更多相关阅读请进入《jQuery》频道 >>




打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...

    暂无评论...