dongyu3967 2016-10-12 14:08
浏览 43

我的XMLhttprequest中没有得到任何回复,

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);
?>

</div>
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 蓝桥oj3931,请问我错在哪里
    • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
    • ¥15 关于#Java#的问题,如何解决?
    • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算
    • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
    • ¥15 cmd cl 0x000007b
    • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line
    • ¥500 火焰左右视图、视差(基于双目相机)
    • ¥100 set_link_state
    • ¥15 虚幻5 UE美术毛发渲染