當我點擊提交按鈕,我不能接受的價值yearend
。相反,我得到了一個未定義的值。點擊提交按鈕後,如何獲得yearend
值?如何使用AJAX數據變量使用的情況下提交按鈕
我的代碼:
$("#company").change(function() {
$("#dFrom").val("");
$("#dTo").val("");
var pass_code = $("#company").val();
var callpage = "dentrycomp.php?pass_code=" + pass_code
var yearend= null;
$.ajax({
type: "GET",
url: callpage,
async: false,
success: function(data) {
yearend= data,
$("#content").html("")
$("#content").html(data)
}
});
//var yearend = "<?php echo $_SESSION['yearend'] ; ?>"
alert(yearend +"company");
this alert box getting the right value yearend.i want that value recieve in under submit button
return true;
});
$('#submit').live('click',function() {
//var yearend = "<?php echo $_SESSION['yearend'] ; ?>"
alert("this is submit button"+yearend);
你能否解釋一下?你在註釋掉的語句是執行它還是執行這個確切的代碼? –