我面临着类似的问题,到运行的WordPress在我的虚拟机实例这样的问题:袅袅不工作的谷歌计算引擎
我使用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。除了这个“卷曲”部分,一切都很好。使用ajax登录并使用AJAX更新配置文件工作正常。
请告诉我如何解决它,或者有没有其他方法可以实现?
curl是否安装在您的vps上?你遇到了什么错误?你检查Apache的错误日志? –
我没有收到任何错误。而通过ajax发送mobile_number的前端页面不会在chrome开发人员工具控制台上显示任何错误,而不会完成ajax请求。我想我需要在谷歌计算引擎上做一些卷曲配置,或者可能是一些php.ini配置,但我是新的谷歌云平台和idk如何做到这一点。 – devkabiir
如果ajax从未完成,那么curl可能只是试图连接并且没有超时。尝试设置超时。检查phpinfo页面以确认curl插件已安装。还要在那里添加一些日志记录,以查看您通过脚本获得了多少距离,以便找到您要暂停的位置,并再次检查apache错误日志,因为这是所有php错误都会发生的地方,包括您没有看到的错误。 –