时间:2021-07-01 10:21:17 帮助过:5人阅读
代码如下:
/* * To change this template, choose Tools | Templates * and open the template in the editor. */ var xmlHttp; function getValue(){ alert("getvaluel"); var question =document.insertForm.question.value; // alert(question); var answer = document.insertForm.answer.value; // alert(answer); submit(question,answer); }; function submit(question,answer){ xmlHttp=GetXmlHttpObject(); if (xmlHttp==null) { alert ("Your browser does not support AJAX!"); return; } xmlHttp.onreadystatechange =function(){ if(xmlHttp.readyState ==4){ alert(xmlHttp.responseText); } }; var url = "insert1.php"; xmlHttp.open("post",url,true); xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=utf-8"); xmlHttp.send("question="+question+"&answer="+answer); } function GetXmlHttpObject() { var xmlHttp=null; try { // Firefox, Opera 8.0+, Safari xmlHttp=new XMLHttpRequest(); } catch (e) { // Internet Explorer try { xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); } } return xmlHttp; }
/* * To change this template, choose Tools | Templates * and open the template in the editor. */ //echo $_POST["question"]; //echo $_POST["answer"]; $q =$_POST['question']; $a = $_POST['answer']; //$q='qq'; //$a="a"; $con = mysql_connect("localhost","joe","123"); if (!$con) { //die('Could not connect: ' . mysql_error()); echo 'Could not connect: ' . mysql_error(); } mysql_select_db("joe",$con); mysql_query("INSERT INTO message VALUES ('$q', '$a', '无')"); mysql_close($con); echo "输入成功"; ?>
以上就介绍了AJAX asp.net分页 ajax php 实现写入数据库,包括了AJAX asp.net分页方面的内容,希望对PHP教程有兴趣的朋友有所帮助。
< 上一篇
flashplayer10官方下载PHP生成的XML以FLASH获取为乱码终极解决
下一篇 >
甘肃省工商行政管理局网上业务办理系统一些PHP管理系统程序中的后门
记住我的登录 忘记密码?
登录
我已阅读用户协议及版权声明
注册