更新时间:2022-04-09 04:24:36
jQuery.load 是异步,您正在尝试在JSON实际加载之前对其进行解析.使用 jQuery.getJSON 加载内容,进行解析并提供可绑定到的回调
jQuery.load is asynchronous, you're trying to parse the JSON before its actually loaded. Using jQuery.getJSON loads the content, does the parsing and provides a callback you can bind to.
jQuery.load将内容加载为HTML并设置所选元素的innerHTML,您也可以在此处绑定complete
处理程序,但是通过将内容加载为HTML然后使用
jQuery.load loads the content as HTML and sets the innerHTML of the selected element, you could bind the complete
handler here aswell, but you may encounter issues by loading the content as HTML and then using text
to retrieve it from the DOM as some parts of your JSON may be interpreted as HTML elements.
***使用这个:
$(document.body).on('change', '.select' , function () {
var identification = $(this).val();
$.getJSON(
'analysis.php?data=' + identification + ' #data',
function (data) {
console.log(data);
}
);
});