Home  >  Article  >  Backend Development  >  生手对jQuery不是很懂,求帮个忙

生手对jQuery不是很懂,求帮个忙

WBOY
WBOYOriginal
2016-06-13 11:56:14876browse

新手对jQuery不是很懂,求帮个忙
我写了一个的temper.html页面去调用http://hys2013.sinaapp.com/SQL.php页面的内容,我照着网上的例子来怎么不行啊(页面不弹窗)
temper.html:

<html><br /><head><br /> <br /><script type="text/javascript" src="/jquery/jquery.js"></script><br /><script type="text/javascript"><br />$.post("http://hys2013.sinaapp.com/SQL.php",function(data){ alert("Data Loaded: " + data); });<br /></script><br /></head><br /><body><br /><br /></body><br /></html><br />


http://hys2013.sinaapp.com/SQL.php:
<? <br /><br /> $mysql = new SaeMysql();<br /> $conn = mysql_connect(SAE_MYSQL_HOST_M.':'.SAE_MYSQL_PORT,SAE_MYSQL_USER,SAE_MYSQL_PASS);<br /> //if($conn){ $action="连接成功"; echo "document.write('".$action."');n";		}				<br /> $sql="SELECT  * FROM  `temp` WHERE id = ( SELECT MAX( CAST( id AS UNSIGNED ) ) FROM temp )";//获取最大ID的那一行		<br /> $row=$mysql->getLine($sql);<br /> foreach ($row as $key=>$value)<br />    {					      <br />      $insert_id=$value;<br />	  break;//目前只需要id所以无需遍历所有值<br />     }<br />echo $insert_id;<br />?> 

求大神给看看应该怎么改一下
------解决方案--------------------
jQuery.post第二个参数是附加参数,第三个参数才是回调吧
$.post("http://hys2013.sinaapp.com/SQL.php", '', function(data){ alert("Data Loaded: " + data); });
------解决方案--------------------
语法
jQuery.post(url,data,success(data, textStatus, jqXHR),dataType)
参数 描述
url 必需。规定把请求发送到哪个 URL。
data 可选。映射或字符串值。规定连同请求发送到服务器的数据。
success(data, textStatus, jqXHR) 可选。请求成功时执行的回调函数。
dataType
可选。规定预期的服务器响应的数据类型。
默认执行智能判断(xml、json、script 或 html)。


第 8 行以后不要!
改作 echo $row['id'];

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn