我查看了我的代码并意识到脚本存在一些问题。现在我已经对它进行了分类,它将不会通过检查您是否拥有正确的资金。我认为这与我声明变量
的方式有关<script type="text/javascript">
var money = "<?php echo $ir['money']; ?>";
var price = 5000;
function openAccount() {
var c = confirm("Are you sure you want to open a bank account for <?=money_formatter(price)?>?");
if(c) {
$('#main_text').html('Opening account');
$('#main_text').append('Checking you have the correct funds');
if(+money < +price) {
$('#main_text').append('<span style="color: red;">Incorrect funds, You need another <?=money_formatter((price)-$ir["money"])?>...</span>');
} else {
$.post('<?=file?>?open=true&print=1', function(data) {
if(data == 'not_enough_money') {
$('#main_text').append('Incorrect funds...');
} else if(data == 'opened') {
$('#main_text').append('You have succesfully opened your brand new bank account!<a href="javascript:void(0);">>View Account</a>');
}
});
}
}
}
答案 0 :(得分:0)
你只是忘记了两个引号。
替换<a href="javascript:void(0); onClick=new_account();">
通过<a href="javascript:void(0);" onClick="new_account();">
,一切都会奏效。