json_decode不输出任何内容(尝试从外部 php 文件中获取json_encode数据)


json_decode outputs nothing (trying to get json_encode'd data from external php file)

In _check_existing_transaction_partners.php

echo '<pre>';
print_r($ajax_existing_company_error);
echo '</pre>';

使用json_encode我对此发表评论。现在仅作为示例显示

输出此

Array
(
    [0] => 1
    [1] => 2
)

echo json_encode($ajax_existing_company_error);

输出此["1","2"]

Jquery代码将数据发送到外部文件并接收回来

var checkbox_to_update = $("#checkbox_to_update").val();
$.post("_check_existing_transaction_partners.php", { 'checkbox_to_update': checkbox_to_update }, function(data, success) {
alert(data);
}, "json");

有了alert(data); 1,2弹出。到目前为止一切都好。


尝试而不是弹出获取其他格式(处理后者)

尝试了$('#json_load').val(data);<div id="json_load"></div>.什么也没看到

然后尝试了$myArray = json_decode($ajax_existing_company_error);<?php print_r($myArray); ?>也什么也没看到。

请告知如何获得$myArray = json_decode($ajax_existing_company_error);$('#json_load').val(data);

更新

关于json_decode _check_existing_transaction_partners.phpecho json_encode($ajax_existing_company_error);

然后jquery

var checkbox_to_update = $("#checkbox_to_update").val();
$.post("_check_existing_transaction_partners.php", { 'checkbox_to_update': checkbox_to_update }, function(data, success) {
<?php print_r(json_decode($ajax_existing_company_error)); ?>
}, "json");

使用视图源,看不到与json_decode相关的任何内容

然后在关闭</body>之前放置<?php print_r(json_decode($ajax_existing_company_error)); ?>。也什么也没看到

对于div,你不使用val():你使用html()text()

$('#json_load').val(data); 

应该是

$('#json_load').html(data);  // or
//$('#json_load').text(data);