ORDER レコードを削除するページがあります。このページは、完全に機能する AJAX から呼び出されました。ただし、在庫テーブルを同時に更新するために作成したコードを追加したことがあります。どうやらAJAX機能が誤動作しているようで、何が悪いのかわかりません。私に提案してください。前もって感謝します。
私の AJAX 関数 (order_edit.asp)
<script language="JavaScript">
var HttPRequest = false;
function doCallAjax(ID) { // delete order
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 = '../engine/delorder_edit.asp';
var pmeters = "tID="+ID;
var bill_id = document.getElementById('bill_id').value; // additional for delorder_edit.asp
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 == 4) // Return Request
{
if(HttPRequest.responseText == 'Y')
{
document.getElementById("tr"+ID).style.display = 'none';
}
}
}
}
</script>
私のdelorder_edit.aspページ
<%
Option Explicit
Dim strID
strID = Request.Form("tID")
Dim Conn,strSQL,objExec
Set Conn = Server.Createobject("ADODB.Connection")
Conn.Open "DRIVER=Microsoft Access Driver (*.mdb);DBQ=" & Server.MapPath("../database/TKP.mdb"),"" , ""
'********** *****************************
'Open recorset in order to add od_qty back to tbl_inventory before this record was removed
'****** Once I added these code, my ajax became malfunction ******
Set rsOrder = conn.Execute("SELECT * FROM tbl_order WHERE od_id = "&strID&"" )
pd_id = rsOrder.fields.item("pd_id")
od_qty = rsOrder.fields.item("od_qty")
od_qty = DzToPcs(od_qty)
strSQL1 = "UPDATE tbl_inventory SET inv_qty_act = inv_qty_act + " & od_qty & ", inv_date = date() WHERE pd_id = '" & pd_id & "'"
Set objExec = Conn.Execute(sql1)
'*******************************************
strSQL = ""
strSQL = strSQL&"DELETE * FROM tbl_order "
strSQL = strSQL&"WHERE od_id = "&strID&" "
Set objExec = Conn.Execute(strSQL)
If Err.Number = 0 Then
Response.write("Y")
Else
Response.write("N")
End IF
Conn.Close()
Set Conn = Nothing
%>