JavaScript中Add方法folders JavaScript框架编程

jQuery的ajax应用

jQuery ajax的前台代码:
<script type="text/javascript" src="/include/jquery/jquery-1.1.3.1.pack.js"></script>
<form name="form1" id="form1" action="ajax.php?action=1" method="post">
  <input type="hidden" id="comid" name="comid" value="111">
  <input type="hidden" id="jobid" name="jobid" value="222">
  <input type="hidden" id="userid" name="userid" value="333">
  <input type="submit" /></form>
<script language="javascript">
$("#form1").submit
    (
       function()
        {
        login();
        return false;
        }
    );
function login()
{
var comid = $("#comid").val();
var jobid = $("#jobid").val();
var userid = $("#userid").val();
$.ajax({
    type: "POST",
    url: "../include/ajax.php",
    data: "action=1" + "&comid=" + comid + "&jobid=" + jobid + "&userid=" + userid,
    beforeSend: function(){
    },
    success: function(msg){
  if(msg=="success"){
alert("求职信息,已经提交!请等候通知!")
   }else {
       alert("信息已发送,请不要重复提交!");
    }
    }
});
}
</script>
PHP的后台代码:
<?
header("Cache-Control: no-cache");
require_once("function.php");
switch ($_POST["action"]){
case 1:
$comid=verify_id($_POST["comid"]);
$jobid=verify_id($_POST["jobid"]);
$userid=verify_id($_POST["userid"]);
$appdate=time();
$hasapp=getValue("select * from csj_appjob where jobid=$jobid and userid=$userid and comid=$comid","id");
if($hasapp==""){
$sql="insert into csj_appjob(comid,jobid,userid,appdate) values($comid,$jobid,$userid,$appdate)";
query($sql);
echo "success";
}else{
echo "wrong";
}
break;
default:
break;

}
?>
TAG: jquery实例 ajax实例
kimi post in Jquery框架 at 2007-09-18 22:02:02.
永久地址:http://ijavascript.cn/jquery/jquery-ajax-100.html
在百度中搜索《jQuery的ajax应用》。

发表评论

发表评论

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>

网友评论仅供网友表达个人看法,并不表明本网同意其观点或证实其描述。