
好吧,我自己找到了解决问题的办法。
我发送了GET类型的AJAX调用,并以String参数的形式传递了数据,并添加了success属性以确认我的代码是否有效。我还更改了Award.php代码,以成功捕获传递的参数。
所以我文件的源代码是:
awards.js
function onAdd() { $("#display").load(filePath); $.ajax({ type: "GET", url: 'controller/Action.php', data: "functionName=add", success: function(response) { alert(response); } });}function onSave() { $("#display").load(filePath); $.ajax({ type: "GET", url: 'controller/Action.php', data: "functionName=save", success: function(response) { alert(response); } });}Award.php
$functionName = filter_input(INPUT_GET, 'functionName');if ($functionName == "add") { add();} else if ($functionName == "save") { save();}function add(){ $award = new Award(); $method = $award->addFunction(); echo json_enpre($method);}function save(){ $award = new Award(); $method = $award->saveFunction(); echo json_enpre($method);}欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)