jQuery ajax的前台代碼編寫

來源:互聯網
上載者:User

標籤:bre   else   ase   wrong   res   post   turn   user   sap   

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(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個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.