扫码关注官方订阅号
84669人学习
65727人学习
82984人学习
467778人学习
498837人学习
471966人学习
256484人学习
152542人学习
224170人学习
139536人学习
81804人学习
85022人学习
11944人学习
20001人学习
60816人学习
5487人学习
15007人学习
2150人学习
6980人学习
194925人学习
359900人学习
1142人学习
19058人学习
3206人学习
180550人学习
48569人学习
17603人学习
40936人学习
1049人学习
750人学习
32909人学习
首先需要一个带输入表格.
复制代码 代码如下:
/* * 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教程有兴趣的朋友有所帮助。
微信扫码关注PHP中文网服务号
QQ扫码加入技术交流群
扫描下载App
Copyright 2014-2024 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
精品班
技术支持
技术咨询
学习群
会员优惠
返回顶部