无法从 javascript 调用 Controller 中的远程方法。
JavaScript 代码:
Visualforce.remoting.Manager.invokeAction(
'{!$RemoteAction.FitAssistenceController.updateObesityGoal}',
WeightValue,CaloriesValue,pastGoalRecommendedSteps,walkingSpeed,
function(result, event) {
console.log("event",event);
console.log("result",result);
}
);
远程方法:
@RemoteAction
global static void updateObesityGoal(String weightGoal,String calChange,String RecommendedSteps,String walkingType){
/* perform the action */
}
这在除 safari 之外的所有浏览器中都运行良好。
客户端错误如下所示:
[Error] XMLHttpRequest cannot load https://fitblissdev17-dev-ed--c.na40.visual.force.com/apexremote due to access control checks.
request (VFRemote.js:42:137)
request (VFRemote.js:74:225)
doSend (VFRemote.js:96)
combineAndSend (VFRemote.js:96:100)
g (VFRemote.js:79:99)
[Error] Visualforce Remoting Exception: Unable to connect to the server (communication failure).
Object
Could not fetch properties. Object may no longer exist.
error (VFRemote.js:117:461)
(anonymous function) (VFRemote.js:134:160)
fire (VFRemote.js:52)
fireEvent (VFRemote.js:47:170)
onProviderData (VFRemote.js:86:195)
fire (VFRemote.js:52)
fireEvent (VFRemote.js:47:170)
onData (VFRemote.js:94:464)
handleFailure (VFRemote.js:75:380)
a (VFRemote.js:39:392)
(anonymous function) (VFRemote.js:40:309)
最佳答案
我猜您是在单击按钮时调用 JavaScript 函数?
如果是这样,我会尝试使用 true 按钮:
<button type="button" onclick="remoteCall();">Click Me!</button>
关于javascript - salesforce 中的远程操作不适用于 safari,但适用于所有其他浏览器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48123193/