我在尝试在我的应用程序中执行POST请求时遇到问题并且我搜索了很多,但是我找不到解决方案.
所以,我有一个nodeJS应用程序和一个网站,我正在尝试使用此站点的表单进行POST请求,但我总是这样做:
在控制台中我看到:
Uncaught TypeError: Cannot read property 'value' of null
Post "http://name.github.io/APP-example/file.html " not allowed
Run Code Online (Sandbox Code Playgroud)
在这行代码中:
file.html:
<form id="add_Emails" method ="POST" action="">
<textarea rows="5" cols="50" name="email">Put the emails here...
</textarea>
<p>
<INPUT type="submit" onclick="sendInvitation()" name='sendInvitationButton' value ='Send Invitation'/>
</p>
</form>
<script src="scripts/file.js"></script>
Run Code Online (Sandbox Code Playgroud)
file.js:
function sendInvitation(){
var teammateEmail= document.getElementById("email").value;
Run Code Online (Sandbox Code Playgroud)
我阅读了很多帖子和跨域文档,但它没有用.研究来源1:http://enable-cors.org/server.html 研究来源2:http://www.w3.org/TR/2013/CR-cors-20130129/#http-access-control-max-年龄
我现在在做什么:
我正在尝试从我的服务器的不同域POST:
POST REQUEST: http://name.github.io/APP-example/file.html,github repository
POST LISTENER:" http://xxx.xxx.x.xx:9000/email,server localhost(x->我的ip地址)
所以,我在其他文件中遇到了同样的问题,但是我修复了它将这段代码放在每条路径的开头:
var express = require('express');
var sha1 = require('sha1');
var router …
Run Code Online (Sandbox Code Playgroud)