can anybody see anything wrong in this XML HTTP POST?

Posted on 2011-10-11
Last Modified: 2012-05-12

Thank you for taking a look at my question.  I have the basic html page with a little java in it, all I want to do it post some XML data to an API.  Can anyone see where I am going wrong if anywhere?

This is the only error I can get to come up. : server does not support RFC 5746, see CVE-2009-3555

Your help is most appreciated!!


function connect(url,params)
var $cnct;  // The variable that makes Ajax possible!
try{// Opera 8.0+, Firefox, Safari
alert ("Firefox selected");
$cnct = new XMLHttpRequest();}
catch (e){// Internet Explorer Browsers
$cnct = new ActiveXObject("Msxml2.XMLHTTP");}
catch (e){
$cnct = new ActiveXObject("Microsoft.XMLHTTP");}
catch (e){// Something went wrong
return false;}}}
$"POST", "",true);
//$cnct.setRequestHeader($cnct, "close");
$params = '<?xml version="1.0" encoding="utf-8"?><PDRequest xmlns:xsd=""  xmlns:xsi=""><MCode>T101</MCode><ACode>TGJHFGDG#%</ACode><RType>Email</RType><PtAmount>300</PaymentAmount><PReference>123456</PReference><CEmail>Yes</CEmail><CReference>No</CReference><RName>J Murphy</RecipientName><REmail></REmail></PDRequest>';

    <FORM method="POST" name="ajax" action="">                  
         <INPUT type="BUTTON" value="Submit"  ONCLICK="connect('test','test')">
         <INPUT type="text" name="dyn"  value="">
Question by:mavmanau
    LVL 40

    Expert Comment

    try with simple http rather than https

    Author Comment

    it didn't work either...I haven't done anything wrong in the xmlhttprequest at all have I?
    LVL 40

    Expert Comment

    where do you get this error? which browser?

    Author Comment


    All I really want to do, is upload some XML - to a REST endpoint.

    Can you see anything wrong in how I am going about the connection etc?  from what I have seen it looks to be exactly how it should be in order to work.

    Author Comment

    I only see the error in the debug part of firefox.  not sure if it is a warning or an error, from what I have seen on other sites from googling, the system should still try to get through anyway
    LVL 82

    Accepted Solution

    $"POST", "", true);
    when you set the third argument to true, you are sending an ASYNCHRONOUS request.  Thus you cannot retrieve the responseText immediately after send() because the request has not completed;

    alert( $cnct.responseText );

    For that to work you will need to send a SYNCHRNOUS request instead:
    $"POST", "", false);

    IF you opt to use false instead, then you CAN use:
    alert( $cnct.responseText );

    If you actually want to keep true as the third argument (meaning if you really want to use an ASYNCHRONOUS request, you will need to "register" a callback function via the onreadystatechange attribute of the xmlhttp object and monitor the progress of the request.  Once you determine that the request has completed then you then use the responseText.  Here's an implementation of what you are trying to accomplish which CORRECTLY uses true as the third argument:

    Author Comment

    awesome thank you, I shall have a play with it.

    Author Closing Comment

    Thank you for your help!! muchly appreciated.

    Featured Post

    Enabling OSINT in Activity Based Intelligence

    Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

    Join & Write a Comment

    Introduction HyperText Transfer Protocol ( 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…
    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…

    754 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

    20 Experts available now in Live!

    Get 1:1 Help Now