Created
January 19, 2019 08:59
-
-
Save ayuLiao/f10879f146cdbca05d8097c5f422b63d to your computer and use it in GitHub Desktop.
页面加载完后,执行ajax,需要使用jquery这个库,页面的DOM加载完后,直接执行,如果使用window.load需要等待页面中的图像也加载完成
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var onLoginSuccess = function (data) { | |
console.log(data); | |
}; | |
//页面中DOM结构加载完后,直接执行 | |
$(function() { | |
var ajaxObj = { | |
type: 'GET', | |
url: 'http://127.0.0.1:8000/api/albumstyles', //URL上一定要带HTTP,不然报错 | |
success: onLoginSuccess, //ajax成功,前端的回调函数 | |
dataType: "json" | |
}; | |
$.ajax(ajaxObj); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment