Ajax帖子和电话盖



我创建了一个安息的Web服务,当我使用Postman通过帖子发送JSON数据时,它可以正常工作,但是一旦我尝试通过我的电话盖Page通过Ajax帖子发送某些内容,电话盖页页面的URL以某种方式连接到下面定义的URL:

<script>
    $(document).ready(function(){  
        $('#submit').click(function(){  
            $.ajax({  
                url:"http://localhost:8080/rest/user/",  
                type:'post',
                data : {
                    "id": 4,
                    "firstname": "Max",
                    "lastname": "Mustermann"
                },      
                dataType: 'JSON', 
                success: function(res, status, xhr){
                    console.log(res);
                } 
            });  
        });  
    });      
</script>

查看Firefox控制台中的帖子方法突然看起来像这样:

http://192.168.1.102:3000/proxy/http://localhost:8080/rest/user/

为什么会发生这种情况?如何防止这种行为?

预先感谢!

编辑:用实际IP地址替换Local主机时,Firefox控制台中的URL看起来正确,但某种程度上仍然不起作用...

现在正在工作:

  1. 用实际的IP
  2. 替换本地主机
  3. 启用的cors如下所述:https://spring.io/blog/2015/06/08/cors-support-in-spring-framework
  4. 使用json.stringify作为我的数据

我认为您已经打开了任何VPN服务或代理服务器。这就是为什么URL通过您的代理地址192.168.1.102:3000/proxy

最新更新