这是在一个HTML文件中。在该else
部分中,我想调用页面show-form();
中的函数example.php
。另外,完整的语法是$.post();
什么?
<script type="text/javascript">
function nis(id){
$(id).show("slow").delay(4000).hide("slow");
}
$(function() {
setAutoComplete("searchField", "results", "autocomplete.php?part=");
$('form[name=frm]').submit(function(event) {
if($("#searchField").val().length===0)
{
nis('.divmsg');
return false;
}
else {
$.post("example.php", function() {});
}
});
});
</script>
这是在example.php
.. 中,用于为您在 searchField 中编写的任何单词提供声明。
<?php
function show_form()
{
echo'<div class="divmsg"> Wronge input :: </div>';
echo' <form name="frm" method="post" action="index.php?act=sm"> ';
echo'<p class="textplz">Tybe a Definition you want ?!';
echo'<p id="auto" >';
echo'Word : <input id="searchField" type="text" name="searchField" /> <input id="for-submitbutton" type="submit" name="sbm" value="Definition" /> ';
echo' </p> </p> </form>';
}
function submited()
{
require("dbconn.inc");
$word=$_POST['searchField'];
$sql="select * from definition where word like '".$word."'";
$result=mysql_query($sql,$con);
if(@mysql_num_rows($result)!=0)
{
while($rows=mysql_fetch_array($result))
{
$vie=$rows["declation"];
}
echo('
<br />
<br />
<form name="frm" method="post" action="index.php?act=sm"> <p id="auto" >
Word : <input id="searchField" type="text" name="searchField" /> <input id="for-submitbutton" type="submit" name="sbm" value="Definition" />
</p> </form> ');
echo('<div class="answer">');
print $word ;
echo('<br><p id="dev">');
print $vie;
echo ("</h4><br></p></div>");
}
}
?>