【发布时间】:2018-10-17 06:34:18
【问题描述】:
if ('all_products' == select_mode) {
var url = '/wp-content/plugins/wplab-custom-code-master/wplab-custom-code.php';
var request = jQuery.get(url);
request.done( function( response ) {
console.log(response);
checked_items = response;
});
request.fail( function ( xhr, ajaxOptions, thrownError ) {
console.log(xhr.status);
console.log(thrownError);
});
}
if (!defined('ABSPATH')) {
exit; // Exit if accessed directly.
}
ini_set('display_errors', 1);
ini_set('error_reporting', E_ALL);
$args = array(
'numberposts' => -1,
'fields' => 'ids',
'post_type' => 'product',
'post_status' => 'publish'
);
$product_ids = get_posts( $args );
return $product_ids;
当我运行代码时,js代码中的url变量导致未定义,但是你如何看到变量被声明了。为什么?
其次,一次 js 代码工作时,ajax 调用返回内部服务器错误。为什么?
谢谢。
【问题讨论】:
-
"js 代码中的 url 变量未定义" -> 你在哪里/如何测试它的值?您确实为它分配了一个值,因此它不能在同一个块中未定义。
-
您检查浏览器控制台是否有错误?请发布给您的错误。认为阅读的人不知道你想用你的程序做什么......
-
控制台中的错误是内部服务器错误(错误500),但我无法返回错误来源。
-
我试图调试 php 文件,问题是函数 get_posts() 返回正确的响应但在自身破坏之后。为什么?能不能用get_posts()函数调试下载wordpress解决方案和调试文件的功能。
标签: javascript php variables request undefined