Why AJAX doesn't work once I add these code?

Jujuba

New Member
I have a page for deleting ORDER record. This page was called from AJAX, which work perfectly. However once I added some code that I made for updating inventory table at the same time. It seemed that AJAX function became malfunction and I can't figure out what is wrong with them. Please suggest me. Thanks in advance.My AJAX function (order_edit.asp)\[code\]<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>\[/code\]My delorder_edit.asp Page\[code\]<% 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%>\[/code\]
 
Back
Top