[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 447
  • Last Modified:

AJAX POST failure

The need is for (1) AJAX POST, (2) cross-domain and (3) issued from one server to another.  To test the code I set up a simple ASP page with the AJAX call to a second page in this case in the same web site.  It fails at line 14 on the AJAX call doing the post, the exception caught at line 18 is error number minus 2147467259, the name of the exception is "Error" with no description or message.  How do I fix this to accomplish my 3 goals?

Calling page
<%@ Language = javascript%>
<%
function ajTrade(keepOn,opt,parm) { 
  var xmlHttp;
  xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");

   xmlHttp.onreadystatechange=function() { processResponse(xmlHttp,opt) }
   var str="opt="+opt;
   for(i=2; i<arguments.length;){
     parm=arguments[i++];
     str+="&p"+(i-2)+"="+escape(parm);
   } 
   try {
     xmlHttp.open("POST",("ajTestReceive.asp"),(keepOn?true:false));
     xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
     xmlHttp.send(str);
   }
   catch (e) {
     var aaa=1;
     debugger
   }
}
function processResponse(xmlHttp,opt,txt) {
  if(xmlHttp.readyState==4) {
    if (xmlHttp.status == 200) {
      debugger
      var aaa=1;
    }
    else {
      debugger
      var aaa=1;
    }
  }
}

ajTrade(true,"testStr_1","testStr_2");
%>

Open in new window


receiving page, ajTestReceive.asp
<%@ Language = javascript%>
<!--#include file="iba_serverside.js"-->
<%
  Response.expires=-1;
debugger

  Response.write("");
  Response.End;
%>

Open in new window

0
Bob3975
Asked:
Bob3975
  • 2
1 Solution
 
Slick812Commented:
greetings  Bob3975, , I can help with your Javascript, But I do not do much with MS  ASP code,

your javascript is just wrong for Ajax
0
 
Dave BaldwinFixer of ProblemsCommented:
@Slick812, that is Jscript to run on the server, not javascript to run in a browser.  It still might be wrong.  Here's a different version from Microsoft: http://msdn.microsoft.com/en-us/library/windows/desktop/ms766431%28v=vs.85%29.aspx
0
 
Bob3975Author Commented:
DaveBaldwin, it was the use of Msxml2.ServerXMLHTTP.6.0 that was needed, thx.
0
 
Dave BaldwinFixer of ProblemsCommented:
You're welcome, glad to help.
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now