从Javascript表单调用类方法
Call a class method from Javascript form
为了动态创建表单,我(在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表单是由类"users"(f.setAttribute('action', "users/register");
)中名为"register"的方法处理的
但我得到的只是一个错误500内部服务器错误。和在CodeIgniter日志中:
An Error Was Encountered. The action you have requested is not allowed.
有人有主意吗?
此错误似乎是由Security.php生成的,请在config文件夹的config.php中将csrf_protection
更改为false
。
$config['csrf_protection'] = FALSE;
你最好看看下面的链接,以获得更多的参考
http://ellislab.com/forums/viewthread/163976/
相关文章:
- 如何在类内部调用类的方法
- 可以“;超级“;可以在子类的方法内部使用,在不直接引用的情况下调用相应的超类方法
- 在 Array.map() 中调用类方法
- 使用 Babel 转译器导入类并调用带有 ES6 模块的静态方法
- 如何从将在html页面中使用的java脚本中调用java类方法
- 如何使用jQuery通过ajax调用php类方法,但不需要任何php处理程序文件
- 从常规ES6类方法中调用静态方法
- 我应该如何从 html 调用 javascript 类方法
- ES6 从同一类中调用类方法
- 从构造函数调用类方法
- 通过类名点原型点方法名称调用 java 脚本类方法
- 从 html 事件调用 javascript 类方法的正确方法
- 如何调用内部 JavaScript 类方法
- 在主干中调用超类方法
- 如何在 Mootools 扩展类中调用任意父方法
- 从同一类中的另一个方法调用 java 脚本类内的方法
- 抽象类方法调用的for-of循环
- 从另一个对象类方法调用对象及其方法
- 用类方法调用的Javascript事件监听器
- 关于通过exports导出的javascript类方法调用的输入