我试图访问我的php文件使用jquery回显的值。我在apache服务器上运行这个。我的代码是无法访问jquery中的函数参数
我的PHP(findjson.php)文件:
<?php
foreach (glob("*.json") as $filename)
echo $filename;
?>
我的JavaScript/HTML文件
...
<script id='code-js' type="text/javascript">
$(document).ready(function(){
$.get("findjson.php", function(data) {
alert(data); //uncomment this for debug
$('#showdata').html(data);
}, 'text');
});
...
function load(){
var docname = $('#showdata');
Scene.loadObject(docname);
}
的一部分,我想DOCNAME在功能负载设置为数据。我不确定如何继续,尝试了各种方式,并且没有想法。我正在尝试遵循本教程:http://www.tutorialspoint.com/jquery/ajax-jquery-get.htm。我尝试过使用全局变量,但出于某种原因,全局变量在函数(数据)中似乎效果不好(我假设它是一个回调函数)。我也尝试过在函数中使用this.data =数据行,但似乎并没有很好地工作。
其asynchronus,所以你需要$( '#showdata')后'调用加载()HTML(数据);'为什么不能。你只需从$ .get函数中调用'Scene.loadObject'? – Nix
只需在成功回调中加入'Scene.loadObject(data)',忘记'load'? – Bergi