【发布时间】:2010-10-02 09:20:14
【问题描述】:
我正在使用 jQuery、JavaScript 和 PHP。我的Ajax.php 文件只显示
数据。文件 test.php 已将值分配给 JavaScript 函数。
我的问题是我无法从 getList(data) 获取 test.php 分配的值。
我的逻辑有什么问题吗?我该怎么做才能让 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];
}
}
【问题讨论】:
标签: php javascript jquery ajax