首先,请原谅我的英语不好
我在 ubuntu 中使用 jquery/ajax 系统工作
我的代码如下:
index.html
...
<script type="text/javascript" src="js/jquery-1.8.3.min.js"></script>
</head>
<body>
<form name="stuSelForm" id="stuSelForm">
<table id="inputTable">
<tr><td colspan="3" align="center">Stu From</td></tr>
<tr>
<td> </td>
<td>St No : </td>
<td><input type="text" name="StNo" id="StNo" /></td>
</tr>
<tr>
<td></td>
<td>name : <br/> family : </td>
<td><input type="text" name="Fname" id="Fname" /><br/><input type="text" name="Lname" id="Lname" /></td>
</tr>
<tr>
<td colspan="3" align="right"><input type="submit" id="send" name="send" value="show" /></td>
</tr>
</table>
</form>
</body>
<script type="text/javascript" src="js/jscodes.js"></script>
...
js文件:
$(document).ready(function()
{
$('#stuSelForm').submit(function(event)
{
var form = $(this);
inputs = form.find("input");
serializedData = form.serialize();
inputs.attr("disabled","disabled");
$.ajax({
url:'process.php',
type:'POST',
data: serializedData,
dataType:'text',
cache: false,
success : function(data,textStatus,jqXHR){ alert(data); },
error : function(jqXHR,textStatus,errorThrown) { alert(textStatus+jqXHR.status+jqXHR.responseText+"..."); },
complete : function(jqXHR,textStatus)
{
inputs.removeattr("disabled");
}
});
event.preventDefault();
});
});
和process.php:
<?php
header("Content-Type: text/html");
$StNo = $_POST['StNo'];
echo $_POST['StNo'];
?>
现在一切正常,但返回值不是 StNo 这是process.php的全部内容 这很卑鄙
请帮我看看为什么会发生这种情况 这是 php 扩展还是我的错误或者...
tanx 为你提供帮助
最佳答案
听起来 php 没有运行。您是否正在运行 HTML 文件,该文件通过本地主机/服务器或直接从目录调用 php 文件?您需要 php 服务器来评估您的 php 脚本。
关于php - jquery ajax返回整页内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13775691/