我正在编写一个包含三个文本输入的非常简单的Web应用程序 输入用于生成结果,但所有工作都是在Javascript中完成的,因此无需提交表单.我正在尝试找到一种方法来让浏览器存储自动完成的输入值,就像它们是在提交的表单中一样.
我已经尝试手动输入autocomplete ="on",但没有提交表单,浏览器无法知道何时应该存储值,所以这没有任何效果.
我还尝试以具有onSubmit ="return false;"的形式包装输入,但是阻止表单实际提交似乎也阻止了浏览器存储其输入的值.
当然可以手动使用localStorage或cookie来持久保存输入,然后从这些提示中生成自动完成提示,但我希望找到一种能够利用本机浏览器行为而不是手动复制它的解决方案.
我们有一个 Angular 应用程序部署到 DigitalOcean => Ubuntu => Nginx, => www 文件夹,它接受所有 GET 请求。我们调用一些第三方 API,作为响应,第三方通过 POST 访问我们的端点。但 nginx 不允许。它给出了 405 消息。我不是 nginx 专家,有人可以提供一些建议吗?
<html>
    <head>
        <title>405 Not Allowed</title>
    </head>
    <body bgcolor="white">
        <center>
            <h1>405 Not Allowed</h1>
        </center>
        <hr>
        <center>nginx/1.14.0 (Ubuntu)</center>
    </body>
</html>
目前的情绪
我正试图在我的控制器中定义的以下函数中从Angular发出$ http post请求:
$scope.sendUserData = function(){
    var userData = JSON.stringify({
        'firstName': $scope.firstName,
        'lastName': $scope.lastName,
        'email': $scope.email
    });
    console.log(userData); //this prints out the JSON I want
    var config = {
        headers: {
            'Content-Type': 'json'
        }
    };
    $http.post('/api/users', userData, config)
        .success(function(data){
            console.log(data);
        })
        .error(function(data){
            console.log('Error: ' + data)
        });
我有一个Express API,我想通过下面定义的路由处理程序接收这个$ http post请求:
router.route('/users')
.post(function(req, res){
    var user = new User();
    user.firstName = req.body.firstName;
    user.lastName = req.body.lastName;
    user.email = req.body.email;
    user.save(function(error){ //add into mongodb
        if(error){
            res.send(error);
        }
        else{
            res.json({message: 'User created'}); …javascript ×2
angular ×1
angularjs ×1
express ×1
forms ×1
html ×1
mean-stack ×1
nginx ×1
node.js ×1