我需要在我的yii2应用程序中从html表单发送数据.我需要使用ajax从这个表单发送数据并从服务器获取响应以输出它.在yii 1.0中我使用了非常有用的帮助器ajaxSubmitButton,我找不到如何在yii2中使用ajax从表单发送数据.你能告诉我怎么做吗?有没有关于它的文章?
谢谢.
我需要从html标签,引号等中过滤来自hmtl形式的数据。
看来我需要根据http://www.yiiframework.com/doc-2.0/yii-validators-filtervalidator.html编写自己的过滤器回调函数。我在模型中得到了以下规则:
public function rules()
{
return [
[['name', 'email', 'phone',], 'required'],
[['course'], 'string',],
[['name', 'email', 'phone',], 'string', 'max'=>250],
['email', 'email'],
[['name', 'email', 'phone'], function($value){
return trim(htmlentities(strip_tags($value), ENT_QUOTES, 'UTF-8'));
}],
];
}
Run Code Online (Sandbox Code Playgroud)
最后一条规则是我添加的我自己的过滤器。但这是行不通的。标签,空格,qoutes不会从中删除,并且此过滤器甚至没有运行。如何实现我想要的和我做错的事情?
谢谢
我现在正在研究ember.js教程.我在"添加子路线"一章时遇到了问题.我的待办事项列表未显示."todos"模板输出很好,但"todos/index"模板根本不起作用.控制台不显示任何错误.我想这是一些本地问题或一些bug.也许有人已经遇到过类似的问题.这个问题可能是什么原因?我怎么解决呢?谢谢.
HTML:
<html>
<head>
<meta charset="utf-8">
<title>Ember.js • TodoMVC</title>
<link rel="stylesheet" href="css/style.css">
</head>
<body>
<script type="text/x-handlebars" data-template-name="todos/index">
<ul id="todo-list">
{{#each itemController="todo"}}
<li {{bind-attr class="isCompleted:completed isEditing:editing"}}>
{{#if isEditing}}
{{edit-todo class="edit" value=title focus-out="acceptChanges" insert-newline="acceptChanges"}}
{{else}}
{{input type="checkbox" checked=isCompleted class="toggle"}}
<label {{action "editTodo" on="doubleClick"}}>{{title}}</label><button {{action "removeTodo"}} class="destroy"></button>
{{/if}}
</li>
{{/each}}
</ul>
</script>
<script type="text/x-handlebars" data-template-name="todos">
<section id="todoapp">
<header id="header">
<h1>todos</h1>
{{input type="text" id="new-todo" placeholder="What needs to be done?"
value=newTitle action="createTodo"}}
</header>
<section id="main">
{{outlet}}
<input type="checkbox" id="toggle-all">
</section>
<footer id="footer">
<span …
Run Code Online (Sandbox Code Playgroud)