ajax的绑定问题

$('#find').click(function () {
        $(document).ajaxStart(function () {            console.log("!!!!!!!!!!!!!!!1")
        })
        $(document).ajaxStop(function () {            console.log("!222222!!1")
        })
        $.getJSON("1.php",function (msg) {
        })
        })

为什么没有在console 输出任何字符呢?
还有ajax的绑定,这是什么意思呢?我点击我的按钮,然后我就发送ajax请求了,之后回调函数获得数据,这个绑定是干嘛的?

不好意思,没注意。。。我从webstorm里复制前面一段过来。
后面懒得复制了,就自己打上去,没注意。。。
还是没有任何输出呀?

$.getJSON("http://v.juhe.cn/weather/index?callback=?",function (msg) {
            })

如果我请求一个api的话,就不能ajaxStart就不起作用了.

请求本地文件是起作用的,这个是为什么呢?


qq_花开花谢_0
浏览 469回答 1
1回答

小唯快跑啊

你写的是$('#find').click(function () {         $(document).ajaxStart(function () {            console.log("!!!!!!!!!!!!!!!1")         })         $(document).ajaxStop(function () {            console.log("!222222!!1")         })         $.getJSON("1.php",function (msg) {                  } })我觉得应该是$('#find').click(function() {     $(document).ajaxStart(function() {        console.log("!!!!!!!!!!!!!!!1")     })     $(document).ajaxStop(function() {        console.log("!222222!!1")     })     $.getJSON("1.php", function(msg) {          }) })你看看有什么不同。。是不是发现少了一个右括号
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

JavaScript