我有一个页面,我输入卡片的名称,卡片的详细信息通过AJAX呈现.我在这个例子中删除了很多与该问题无关的代码,并且我已经测试了这个简化的代码并且它再现了相同的错误.
神秘的是它在第一次运行testSelectedCardDetails函数时工作正常.它称之为setNameCardIsFromField罚款,并做它本来应该做的事情.第二次通过它死于控制台显示:
Uncaught TypeError: setNameCardIsFromField is not a function
Run Code Online (Sandbox Code Playgroud)
那是怎么回事?老实说,我不知道jQuery如何能够解决这个问题,所以我转向stackoverflow世界,乞求从这种疯狂中获得救赎.;)
function testSelectedCardDetails(cardName) {
var cardTestInfoArray = [];
$.ajax({
url: 'includes/getCardAndSetDataViaAJAX.php',
type: 'POST',
cache: false,
async: false, // if set to true then the data doesn't get here fast enough to run commands in 'success'
dataType: 'json',
data: { callThis: "testSelectedCardDetails", thisCardName: cardName},
error: function(data){
console.log("AJAX failed to get card info.");
},
success: function(data) {
$.map(data, function (value) { cardTestInfoArray = value; });
cardPresentInfo['printings'] = cardTestInfoArray['printings'];
//automatically …Run Code Online (Sandbox Code Playgroud)