Solved

AJAX POST failure

Posted on 2013-05-11
4
441 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Sending ASP to server side 8 28
arrays and radio buttons 10 36
Jquery HTML() with ajax... replacing content 2 26
Hide and Unhide Table 6 24
Introduction HyperText Transfer Protocol (http://www.ietf.org/rfc/rfc2616.txt) or "HTTP" is the underpinning of internet communication.  As a teacher of web development I have heard many questions, mostly from my younger students who have come to t…
The Confluence of Individual Knowledge and the Collective Intelligence At this writing (summer 2013) the term API (http://dictionary.reference.com/browse/API?s=t) has made its way into the popular lexicon of the English language.  A few years ago, …
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…

713 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