【发布时间】:2020-04-05 12:10:35
【问题描述】:
我正在尝试编写一个 Vue.JS 模块来进行一些数据处理并将变量发送到单独文件中的 PHP 函数。我正在使用 Axios 将参数解析为 PHP。现在的问题是,Axios 请求到达了 PHP 文件,但 PHP 并没有真正调用本来打算调用的函数。
来自 Vue 应用的 PHP 调用:
axios.post('./crmFunctions.php',{ params: { function2call:"sendQuery", id:1, mid:1, message: "Hello there!", event:"Query" }})
.then(response => this.responseData = response.data)
.catch(error => {});
PHP解释代码:
if(isset($_POST['function2call']) && !empty($_POST['function2call'])) {
if( !isset($_POST['arguments']) ) { $aResult['error'] = 'No function arguments!'; }{
$function2call = $_POST['function2call'];
switch($function2call) {
case 'sendQuery' : sendQuery($_POST['arguments'][0],$_POST['arguments'][1],$_POST['arguments'][2],$_POST['arguments'][3]);
break;
case 'other' : // do something;break;
// other cases
}
}
}
这段代码哪里出错了?我之前设法在 AJAX 上调用了相同的函数。
【问题讨论】:
标签: javascript php html vue.js axios