我正在使用jQuery,JavaScript和PHP。我的Ajax.php
文件只顯示 數據。文件test.php
已將值分配給JavaScript函數。從PHP到JavaScript的值賦值
我的問題是我不能夠得到由test.php的分配值,從getList(data)
。
我的邏輯有問題嗎?我該怎麼做才能讓test.php分配的值顯示在getList()
函數中?
$.ajax({
type: 'POST',
url: 'ajax.php',
data: 'id=' + id ,
success: function(data){
$("#response").html(data);
if(flag != 0){
flag = 0;
$.get("test.php", function(data){
alert("Data Loaded: " + data);
getList(data);
});
}
} //Success
}); //Ajax
而test.php具有以下內容。
<?php
print "<script language='javascript'>";
print " temp[temp.length]=new Array('STA-VES','East',4500);";
print " temp[temp.length]=new Array('STA-CRF','West',5400);";
print "</script>";
?>
我的JavaScript函數有:
var temp=new Array();
getList(){
alert(temp.length);
for(var i=0; i<temp.length; i++){
var val = temp[i];
}
}
是我得到的警報,但功能的GetList顯示Willnot總lenghth – venkatachalam 2009-01-20 05:08:11