Solved

AJAX POST failure

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

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 82

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 82

Expert Comment

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

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Suggested Solutions

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…
Introduction Got endorsements from your clients?  Great!  There is almost nothing better than word-of-mouth advertising.  But how can you do that on the internet?  Sure you can make a page for endorsement quotations and list them all, but who is …
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…

708 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now