首页 > 代码库 > jQuery ajax的前台代码编写
jQuery ajax的前台代码编写
jQuery ajax的前台代码:
<script type="text/javascript" src="http://www.mamicode.com/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="http://www.mamicode.com/111">
<input type="hidden" id="jobid" name="jobid" value="http://www.mamicode.com/222">
<input type="hidden" id="userid" name="userid" value="http://www.mamicode.com/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(2881064151){
},
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;
}
?>
jQuery ajax的前台代码编写
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。