【发布时间】:2011-03-02 11:43:09
【问题描述】:
我正在尝试从包含<?php
echo 'here is a string';
?> 的名为return 的php 文件中检索数据。我正在通过一个包含 ` 的 html 文件来执行此操作
div {颜色:蓝色; }
跨度{颜色:红色; }
变量 x;
$.get("return.php", 函数(数据){
x = 数据;
})
函数 showAlert() {alert(x);}
$(document).ready(function(){ 警报(x); });
` 当按钮被点击时,它会很好地检索并显示代码,但在页面加载时,它会显示“未定义”而不是 return.php 中的数据。有什么解决办法吗?
【问题讨论】:
标签: javascript jquery html