<head>
  <meta name="description" content="Free Web tutorials">
  <meta name="keywords" content="HTML,CSS,XML,JavaScript">

<script type='text/javascript' src='js/jquery-3.1.1.min.js'></script>
</head>
<title></title>

<body>
  Teste pelo Ajax, retornando a string do cliente
<?php

header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Methods: GET, POST, PATCH, PUT, DELETE, OPTIONS');
header('Access-Control-Allow-Headers: Origin, Content-Type, X-Auth-Token');
?>
<script type='text/javascript'>
$(document).ready(function() {

  alert("Enviando o Comando");

  $.ajax({
	      url:  "http://codesatclinica2017.hopto.org:1001/printXml.php",
				type: "POST", //send it through get method
        async: true ,
        contentType: "application/json",
        dataType: "text",
				data: {
					    // venda: v_xmlvenda,
					    // resp: st_resp
					  },
	      success:function(data) {
					 var str = data;
           console.console.log(str);

           /*
					 var retdata  = str.split(';');
					 var iddocsai = retdata[2];

					 // se retornou 0, vai para lista
					 if(retdata[0]=="0"){
						 redirect = "erpc_faturar_pedidos_list.php";
					 }else{
						 // var iddoccrip = Base64.encode(JSON.stringify(iddocsai));
						 var iddoccrip = window.btoa(iddocsai);
						 redirect = "erpc_nfccode_venda_imprimir.php?id=" + iddoccrip;
					 }
					 window.location = redirect;
           */
	      }
	 });

}(jQuery));

</script>
</body>
