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.php
是echo 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);