提交表单后,我想通过 ajax 请求从 MySQL 检索一些数据,但 getJSON 函数遇到一些问题。
这有效:
$("form[id=bilddatenbank_sortiment_anlegen]").submit(function() {
var array_sortimentsname;
$.getJSON('inc/inc.sortimentsname.php', function(array_sortimentsname) {
console.debug(array_sortimentsname);
});
return false;
});
我需要在 getJSON
函数之外访问 array_sortimentsname
,我该怎么做?
最佳答案
$("form[id=bilddatenbank_sortiment_anlegen]").submit(function() {
var array_sortimentsname;
var parsedJson = null;
$.getJSON('inc/inc.sortimentsname.php', function(array_sortimentsname) {
parsedJson = array_sortimentsname;
//console.debug(array_sortimentsname);
});
console.debug(parsedJson);
return false;
});
像这样吗?我得到一个我的控制台:null
是的,我已经编辑了标题。
关于php - jquery json 和 php mysql 提交检查,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44236856/