<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<form action="#" method="POST" id="st_epic">
<label> EPIC Number</label>
<input type="text" id="epic_num" name="epic_num">
<label>Select State</label>
<input type="text" id="epic_state" name="epic_state">
<button type="submit" tabindex="3" id="sub_epic">Search</button>
</form>
<script>
jQuery(document).ready(function($){
$('#st_epic').submit(function(){
var epic_no = $("#epic_num").val();
var state = $("#epic_state").val();
$.ajax({
url: '/a1.php',
method: 'POST',
data: {epic_no:epic_no, state:state},
dataType: 'json'
}).done(function (response){
if (response.message == 'succes') {
console.log("complte =" + response.data);
var div = document.getElementById('epic_result');
div.html(response.data);
}
});
return false;
})
})
</script>
<div id="epic_result">
</div>
//a1.php file is
<?php
$en = ($_POST['epic_no']);
$es = ($_POST['state']);
$fields = array(
'epic_no' => $en,
'page_no' => 1,
'results_per_page' => 10,
'reureureired' => 'a32412c7-5598-401f-903c-f68a8690d4b1',
'search_type' => 'epic',
'state' => $es,
);
$url = 'http://example.in/Search';
$fields_string = json_encode($fields);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_HTTPHEADER, Array('Content-Type: application/json','Accept: */*'));
curl_setopt($ch, CURLOPT_POSTFIELDS, $fields_string);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
$output = curl_exec($ch);
if(curl_exec($ch) === false)
{
echo 'Curl error: ' . curl_error($ch); }
else
{
$out = json_decode($output, true);
print_r($out);
// echo 'Operation completed without any errors';
}
curl_close($ch);
?>
echo 'Operation completed without any errors';
而不是格式化输出时,它会显示操作已完成而没有任何错误。我没有弄错了什么?如果有人能提供帮助,我将非常感激。从昨天开始找到解决方案仍然没有得到,最后问道。