0

为了动态创建表单,我在做类似的事情(在 js 函数中):

member = memberInfo.values[0];

// create the sign up form
var f = document.createElement("form");
f.setAttribute('method',"post");
f.setAttribute('name',"linkedInForm");
f.setAttribute('action', "users/register");

// add fields to the form
var fName = document.createElement("input");
fName.setAttribute('type',"hidden");
f.setAttribute('name',"linkedInForm");
fName.setAttribute('value',member.firstName);

我正在将字段添加到表单中

// append fields to the form
f.appendChild(fName);

然后提交:

document.getElementsByTagName('body')[0].appendChild(f);

f.submit();

此 js 表单旨在通过名为“用户”类中的“注册”( f.setAttribute('action', "users/register");)的方法进行处理

但我得到的只是一个错误 500 内部服务器错误。在 CodeIgniter 日志中:

An Error Was Encountered. The action you have requested is not allowed.

有人有想法吗?

4

1 回答 1

1

此错误似乎是由 Security.php 生成的,将config 文件夹上的 config.php更改csrf_protection为。false

$config['csrf_protection'] = FALSE; 

您最好查看下面的链接以获取更多参考

http://ellislab.com/forums/viewthread/163976/

于 2013-06-25T11:26:09.383 回答