จะทำตัวเสริชจาก ajax 2 ตัว แล้วเกิด error แก้ยังไงครับ
ผมจะทำตัวเสริชจาก Ajax โดยตรงเสริชจาก ชื่อคอลัม แล้วตามด้วยเนื้อหาอ่ะครับ
แต่ปรากฏว่าผมทำแล้วมันเออเรออ่ะครับ
Code (ASP)
<html>
<head>
<title>ค้นหาศิษย์เก่า</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
</head>
<script language="JavaScript">
var HttPRequest = false;
function doCallAjax(Search,content) {
HttPRequest = false;
if (window.XMLHttpRequest) { // Mozilla, Safari,...
HttPRequest = new XMLHttpRequest();
if (HttPRequest.overrideMimeType) {
HttPRequest.overrideMimeType('text/html');
}
} else if (window.ActiveXObject) { // IE
try {
HttPRequest = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
HttPRequest = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e) {}
}
}
if (!HttPRequest) {
alert('Cannot create XMLHTTP instance');
return false;
}
var url = 'Search2.asp';
//var pmeters = 'mySearch='+Search;
var pmeters = "mySearch=" + Search +
"&mySearch2=" + content;
HttPRequest.open('POST',url,true);
HttPRequest.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
HttPRequest.setRequestHeader("Content-length", pmeters.length);
HttPRequest.send(pmeters);
HttPRequest.onreadystatechange = function()
{
if(HttPRequest.readyState == 3) // Loading Request
{
document.getElementById("mySpan").innerHTML = "Now is Loading...";
}
if(HttPRequest.readyState == 4) // Return Request
{
document.getElementById("mySpan").innerHTML = HttPRequest.responseText;
}
}
}
</script>
<body Onload="JavaScript:doCallAjax('');">
<h1>My Customer</h1>
<form name="frmMain">
<select name="txtContent">
<option value="a_name">ชื่อ</option>
<option value="a_division">สาขา</option>
</select>
Search <input type="text" name="txtSearch" id="txtSearch">
<input type="button" name="btnSearch" id="btnSearch" value="Search" OnClick="JavaScript:doCallAjax(document.getElementById('txtSearch').value,document.getElementById('txtContent').value);">
<br><br>
<span id="mySpan"></span>
</form>
</body>
</html>
Code (ASP)
<!--#include file="connect.asp" -->
<%
Dim strSearch,conSearch
strSearch = Request.Form("mySearch")
conSearch = Request.Form("mySearch2")
Dim strSQL,objRec
'*** Search By Name or Email ***'
strSQL = "SELECT * FROM arumnai "
strSQL = strSQL & "WHERE " & conSearch & " LIKE '%"& strSearch &"%' "
Response.write (strSQL)
Set objRec = Server.CreateObject("ADODB.Recordset")
objRec.Open strSQL, con, 1,3
%>
<table width="600" border="1">
<tr>
<th width="91"> <div align="center">CustomerID</div></th>
<th width="98"> <div align="center">Name</div></th>
<th width="198"> <div align="center">Email</div></th>
<th width="97"> <div align="center">CountryCode</div></th>
<th width="59"> <div align="center">Budget</div></th>
</tr>
<%
While Not objRec.EOF
%>
<tr>
<td><div align="center"><%=objRec.Fields("a_name").Value%></div></td>
<td><%=objRec.Fields("a_division").Value%></td>
<td><%=objRec.Fields("a_type").Value%></td>
<td><div align="center"><%=objRec.Fields("a_year").Value%></div></td>
<td align="right"><%=objRec.Fields("a_workplace").Value%></td>
</tr>
<%
objRec.MoveNext
Wend
%>
</table>
<%
objRec.Close()
Set objRec = Nothing
%>
Tag : ASP, Ms SQL Server 2005, Ajax
Date :
2013-02-04 10:56:02
By :
Clamore
View :
1242
Reply :
3
Load balance : Server 02