Js Angular Bug仅在Safari上 [英] Js angular bug only on Safari

查看:48
本文介绍了Js Angular Bug仅在Safari上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下代码:

$http.post(constants.path+'address.php', {form}).then(function(data){
                console.log(data);
                console.log("success");
            });
        }

仅在Safari上出现以下错误:

Only on Safari I get the following error:

'SyntaxError: Unexpected token '}'. Expected a ':' following the property name 'form'. 

其他所有浏览器都不会抱怨此代码.有什么想法吗?

Every other browser don't complain about this code. Any ideas ?

整个功能是:

function enviaVaga(form){
    console.log(form);
    return $http.post(constants.path+'json.php', {form}).then(function(data){
        console.log(data);
        console.log("sucesso");
    });
}

这是一项将数据发送到我的后端的服务功能

This is a service function to send data to my backend

仅供将来参考,删除{}会导致我的后端希望在 $ formData 上接收到 form 对象的问题,以解决此问题 {form:form} ,在Safari上效果很好.

Just for future reference, removing the {} created the problem that my backend was expecting to receive a form object on $formData, to solve this I use {form: form}, that works well on Safari.

推荐答案

您没有传递对 data 有效的任何内容.Safari尝试将 {form} 解释为新对象.

You aren't passing anything valid for data. Safari is attempting to interpret {form} as a new object.

其他浏览器可能更亲切,但只需放下 {} .

Other browsers may be more gracious, but just drop the { and }.

实际上,其他浏览器可能会将 {form} 解释为Safari浏览器不支持的对象简称.请参阅: https://kangax.github.io/compat-table/es6/#object_literal_extensions

Actually, other browser might be interpreting {form} as object short notation which is not supported by safari. see: https://kangax.github.io/compat-table/es6/#object_literal_extensions

这篇关于Js Angular Bug仅在Safari上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆