0

Simple version, I'm creating a basic test script since we are using an API to a third party server that keeps customer details and in one of my forms I need to send this data to this server before submit for my own site. This third party side just check the information provided and return if the new password selected by the customer is strongest enough based on personal information, etc. The thing is, I can't make a request to this third party page and I tested on different says, basically I tested the following

<html>
<head><title>test</title></head>
<SCRIPT TYPE="text/javascript">
<!--
function loadXMLDoc(param) {
    var xmlhttp;

    if (window.XMLHttpRequest) {
        // code for IE7+, Firefox, Chrome, Opera, Safari
        xmlhttp = new XMLHttpRequest();
    } else {
        // code for IE6, IE5
        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
    }

    xmlhttp.onreadystatechange = function() {
        if (xmlhttp.readyState == 4 ) {
           if(xmlhttp.status == 200){
               document.getElementById("myDiv").innerHTML = xmlhttp.responseText;
           }
           else if(xmlhttp.status == 400) {
              alert('There was an error 400')
           }
           else {
               alert('something else other than 200 was returned')
           }
        }
    }

    xmlhttp.open("GET", param, true);
    xmlhttp.send();
}


function TestDataCheck()
{
var qtytested = document.testform.qtytested.value;
var qtypassed = document.testform.qtypassed.value;
var returnval;

if ( (qtytested != "null") && (qtypassed != "null")){
   var str = qtytested+' '+qtypassed;
   var dest = 'https://AnotherHost/Check?q=str;
   loadXMLDoc(dest);
   returnval = true;
}
else
   {
   alert("Please, choose a new password");
   returnval = false;
   }

return returnval;
}
// -->
</SCRIPT>

<FORM 
   ACTION="../cgi-bin/changepass.pl"
   NAME="testform" 
   onSubmit="return TestDataCheck()" 
   >
<INPUT NAME="qtytested"><BR>
<INPUT NAME="qtypassed" type="password"><P>
<INPUT TYPE=SUBMIT VALUE="Submit">
</FORM>
</html>

This works if I replace param with a static name on my server, for example, mytestscript.cgi - however I can't request the script from another server. How to do it? I don't matter if it's Ajax, JQuery, etc as soon as it work against all major browsers and preferable small. :)

A full sample / example is very welcome.

Thanks.

user1007489
  • 123
  • 1
  • 6

0 Answers0