我的XMLhttp请求中没有得到任何响应,

时间:2016-10-12 14:08:46

标签: javascript php xmlhttprequest

我的代码如下。我对这件事并不是那么专家。如果有人能说出这些代码的错误,需要帮助。我正在向另一个提及 domain 2.com 的域名提出请求。当我在控制台中运行此代码时,它没有任何错误没有响应。我实际上并没有得到正在发生的事情。我已经显示了all.php文件。请任何人可以解释我在做什么错误?

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

0 个答案:

没有答案