Solved

AJAX POST failure

Posted on 2013-05-11
4
440 Views
Last Modified: 2013-05-11
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
Comment
Question by:Bob3975
  • 2
4 Comments
 
LVL 34

Expert Comment

by:Slick812
ID: 39158574
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
 
LVL 83

Accepted Solution

by:
Dave Baldwin earned 500 total points
ID: 39158613
@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
 

Author Closing Comment

by:Bob3975
ID: 39158708
DaveBaldwin, it was the use of Msxml2.ServerXMLHTTP.6.0 that was needed, thx.
0
 
LVL 83

Expert Comment

by:Dave Baldwin
ID: 39158733
You're welcome, glad to help.
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
AJAX pass along a variable 3 46
Json Schema 8 32
Button function on table is in trouble 3 20
Ahax pagination 9 32
This article discusses the difference between strict equality operator and equality operator in JavaScript. The Need: Because JavaScript performs an implicit type conversion when performing comparisons, we have to take this into account when wri…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

792 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question