Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/reporting-services/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
PHP没有jquery函数的输出_Php_Jquery_Ajax_Json - Fatal编程技术网

PHP没有jquery函数的输出

PHP没有jquery函数的输出,php,jquery,ajax,json,Php,Jquery,Ajax,Json,我试图从数据库中获取数据,但我不明白为什么没有得到任何输出。我正在使用jQuery/AJAX: $(document).ready(function(){ $('#banktransfer_blz').blur( function(){ send_blz( $(this).val() ); } ); } ); function send_blz(str){ $.post( "get_swift.p

我试图从数据库中获取数据,但我不明白为什么没有得到任何输出。我正在使用jQuery/AJAX:

$(document).ready(function(){
      $('#banktransfer_blz').blur( function(){
                    send_blz( $(this).val() );
            } );

    } );

function send_blz(str){
      $.post( "get_swift.php", 
          { sendBLZ: str }, 
          function(data){
            $('#banktransfer_bic').val( data.return_bic ).html();
          },
          "json");
    }
下面是get_swift.php:

if (isset($_POST['sendBLZ'])){
$value = $_POST['sendBLZ']; 
}

$test = "test";

$swift = xtc_db_query("SELECT customers_id FROM customers WHERE customers_cid ='20002'"); 


echo json_encode( array( "return_bic" => $swift) ); 
 $swift = xtc_db_query("SELECT customers_id FROM customers WHERE customers_cid ='20002'");
 $row = xtc_db_fetch_array($swift);
 echo json_encode( array( "return_bic" => $row['customers_id']) );

我已连接到数据库。

尝试此操作,您需要使用
xtc\u db\u fetch\u array
从表中获取
客户id

在get_swift.php中:

if (isset($_POST['sendBLZ'])){
$value = $_POST['sendBLZ']; 
}

$test = "test";

$swift = xtc_db_query("SELECT customers_id FROM customers WHERE customers_cid ='20002'"); 


echo json_encode( array( "return_bic" => $swift) ); 
 $swift = xtc_db_query("SELECT customers_id FROM customers WHERE customers_cid ='20002'");
 $row = xtc_db_fetch_array($swift);
 echo json_encode( array( "return_bic" => $row['customers_id']) );
而且

而不是

$('#banktransfer_bic').val( data.return_bic ).html();

尝试使用浏览器的开发工具并检查XHR请求。如果可以,请确保要从中获取数据的页面单独连接到数据库。您可以通过直接从浏览器的URL访问此页面来检查这一点,并且输出应该是您通过ajax想要的

同样在ajax代码中,尝试更改

$('#banktransfer_-bic').val(data.return_-bic.html()


$('#banktransfer_-bic').html(data.return_-bic)

我假设您在直接调用php文件时得到了所需的响应

您正在通过执行
$(“#banktransfer_bic').html()重置
#banktransfer_bic
html


尝试使用:
$('#banktransfer_-bic').html(data.return_-bic)相反

什么是
xtc\u db\u查询
?你不需要取数据吗?