PHP中ajax的局部刷新

找了半天资料跟实例也没整明白,弄的现在做什么事也没心情...
代码如下(比较简略):
<form action="" method="post">
分类列表:<select name="select" id="select"></select>
分类名称:<input type="text" name="fenlei" id="fenlei" />
<input type="submit" name="button" id="button" value="添加分类" onClick="form1.action='#';form1.submit()">

标题:<input type="text" name="biaoti" id="biaoti" />
<input type="submit" name="button" id="button" value="提交标题" />
</form>

我想要的功能是输入[分类名称]点[添加分类]
添加到数据库后,只局部刷新分类列表这行(列表读取分类数据).

帮忙写出这功能的ajax代码
如果能解释代码的含义另追加高分.

最近做的项目用php5开发,现在将使用的局部刷新总结下;1,使用情况是:我点击本页面,要使本页面的某块局部刷新;本页面通过这种方式包含局部页面: <div id="allvideo"><?php require_once("./relation.php");?></div><script type="text/javascript" src="prototype.js"></script>
<script type="text/javascript">
function localRef(){
var url = "relation.php"; //局部包含的页面var pars = "param=" + param + "&type=" + type + "&channelid=" + channelid + "&Page_Num=" + Page_Num + "&Country=" + Country + "&Order_By=" + Order_By; //要传递的参数
var myAjax = new Ajax.Updater(
'allvideo', //把取得的HTML结果更新到的层
url,
{
method : 'get',
parameters : pars,
evalScripts : true
}
);
}2,点击页面局部刷新,并返回值通过js判断;比如,一个局部的留言板,我发送一条数据,局部刷新;并将结果通过js方式告诉我;function addMessage(type,actId,sentences){var sentences = document.getElementById("sentences").value;
var url = "addMessage.php";
var pars = "type=" + type + "&sentences=" +sentences + "&playid=" +actId ;
var myAjax = new Ajax.Request(
url,
{
method: 'get',
parameters: pars,
onComplete: showResponse_addmessage
}
);

}
}//********************************//addMessage.php 页面通过,下面语句将执行的结果返回给js//$rtn = array('result'=>$validate_result,'countnum'=>$vrowNum);//echo json_encode($rtn); //********************************//留言结果判断
function showResponse_addmessage(originalRequest){

logininfo = originalRequest.responseText.evalJSON(true);
if(logininfo.result == "1")
{
alert("成功");
}
else
{
alert("失败");

}
}
温馨提示:答案为网友推荐,仅供参考
相似回答