[英]Variable undefined when declared
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
(在提供的代码块中)不能未定义。
您可以通过console.log
或 debugger 进行检查;
对于 500 错误,首先要检查请求的路由地址。
无法提供有关 php 代码的帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.