0

my code in given below. I am not that much expert in this thing. Need help if any one can tell whats wrong with these code. I am making request to another domain mentioned as domain 2.com. When i run this code in console it doesn't any error not response. I am not getting actually what is happening. The all.php file i have shown. Please any one can explain me what mistake i am making?

      <script>
   //#st_epic When form is submitted
                                 var xhr;
                                        if (window.XMLHttpRequest) {
                                            xhr = new XMLHttpRequest();
                                        }else{
                                            xhr = new ActiveXObject("Microsoft.XMLHTTP");
                                        }


                                             jQuery(document).ready(function($){

                                    $('#st_epic').submit(function(){
                                         xhr.open("get", '/all.php', true);
                                            xhr.setRequestHeader("Content-type","application/x-www-form-urlencoded");
                                               
                                            xhr.onreadystatechange = function() {
                                                if (xhr.readyState == 4) {
             document.getElementById('epic_result').innerHTML =result;
                                                e = null;
            }
           
                                                console.log("Complete = " + xhr.responseText); 
                                                }
                                            }

                                     xhr.send();
                                    return false;
                                    })
                                })
                                            </script>
//'st_epic','epic_state','captcha_img' getting the values from the FORM
<?php
$epic ="";
 $epicstate ="";
 $ecaptcha ="";
 
 if(isset($GET['st_epic'])){
$epic = $GET ['epic_num'];
$epicstate = $GET['epic_state'];
$ecaptcha = $GET ['captcha_img'];
}
 $url = 'http://domain 2.com/';
 $fields = 'Search?epic_no=' .$epic.'&page_no=1&results_per_page=10&reureureired=a32412c7-5598-401f-903c-f68a8690d4b1&search_type=epic&state='.$epicstate.'&txtCaptcha='.$ecaptcha;
 //open connection - initialize cURL handler
 $ch = curl_init();
 curl_setopt($ch, CURLOPT_URL, $url);
 //curl_setopt($ch, CURLOPTPOST, true);
 curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
 curl_setopt($ch, CURLOPT_POST, true);
 curl_setopt($ch, CURLOPT_HTTPHEADER, Array("Content-Type: application/x-www-form-urlencoded","Accept: */*"));
 curl_setopt($ch, CURLOPT_POSTFIELDS, $fields);
 
 //execute post
 $result = curl_exec($ch);
 curl_close($ch);
?>
Mahesh
  • 55
  • 1
  • 8

0 Answers0