我在运行WordPress的VM实例上面临与此问题类似的问题:
我使用AJAX以send_otp.php
作为参数来调用mobile_number
。
我的send_otp.php
脚本是:
$mobile_number = $_POST['mobile_number'];
$url = "http://gateway.com/api?numbers=91" . $mobile_number. "";
// Initiate curl
$ch = curl_init();
// Disable SSL verification
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
// Will return the response, if false it print the response
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
// Set the url
curl_setopt($ch, CURLOPT_URL, $url);
// Execute
$result = curl_exec($ch);
// Closing
curl_close($ch);
$result = json_decode($result, true);
我的Javascript代码如下:
cust_mob = jQuery('#number');
jQuery.ajax({
url: 'send_otp.php',
type: 'POST',
dataType: 'json',
data: {
mobile_nuber: '' + cust_mob.val().toString() + '',
security: '<?php echo wp_create_nonce('mobile-validate-nonce'); ?>'
},
success: function (response) {
console.log('success');
}, error: function (response) {
console.log('success');
}
});
我已经删除了很多代码,只是为了在这里发布,一切都在使用WAMP的本地机器WordPress安装上正常工作。
此代码是我主题的一部分,我所做的就是压缩主题文件夹并在进行更改后将其上传到WordPress。一切都很好,除了这个&#39; curl&#39;部分例如使用ajax登录并使用AJAX更新配置文件工作正常。
请告诉我如何解决它,或者还有其他方法可以解决这个问题吗?