聚合物铁型输出错误
Polymer Iron-Form Output Error
我是 Polymer 的新手,我正在使用 iron-form 组件将 a 提交到数据库。我的问题是我如何能够将错误报告回 iron-form 和 html?我尝试通过 json 数组使用 php echo
和 return。但它没有显示在网页上。我该怎么做呢?这是我的代码:
include('config.php');
//Require the db file
include('db.php');
$db = new db($dbhost, $dbuser, $dbpassword, $dbmaster);
include('function.php');
$secure = new secure();
//Get the string.
$email = $secure->clean($_GET["email"]);
if ($secure->verify_email($email) == 'false') {
echo ' <paper-dialog id="error">
<h2>Error Registering Your Account</h2>
<div>
Invalid Email!
</div>
</paper-dialog> ';
}
我为电子邮件输入了一个错误的输入:asdff,所以它会故意抛出一个错误,但是当我提交它时,当我查看网络选项卡时没有任何显示,我看到:
<paper-dialog id="error">
<h2>Error Registering Your Account</h2>
<div>
Invalid Email!
</div>
</paper-dialog>
我的实际表格代码是:
<form is="iron-form" id="formPost" method="post" action="core/register.php">
<paper-input char-counter error-message="Invalid input!" label="Username" maxlength="25" required name="username"></paper-input>
<paper-input char-counter error-message="Invalid input!" label="Display Name" maxlength="35" required name="displayname"></paper-input>
<paper-input char-counter error-message="Invalid input!" label="Password" maxlength="25" required type="password" name="password"></paper-input>
<paper-input char-counter error-message="Invalid input!" label="Confrim Password" maxlength="25" required type="password" name="cfmpassword"></paper-input>
<paper-input char-counter error-message="Invalid input!" label="Email" maxlength="25" required type="" name="email"></paper-input>
<paper-checkbox required>By checking this box, you agree that you're atleast the age of 13 or above.</paper-checkbox>
<br />
<br>
<div>
<paper-button raised
onclick="submitForm()"><iron-icon icon="check" style="margin-right:5px;"></iron-icon>Register</paper-button>
</div>
</form>
<script type="text/javascript">
function submitForm() {
document.getElementById('formPost').submit();
}
</script>
使用 iron-ajax 时如何显示错误?抱歉,如果我的问题不是那么容易理解,我真的不知道如何表达我的问题。
我发现了方法,我只需要将侦听器 iron-form-error 添加到我的 js 中。
我是 Polymer 的新手,我正在使用 iron-form 组件将 a 提交到数据库。我的问题是我如何能够将错误报告回 iron-form 和 html?我尝试通过 json 数组使用 php echo
和 return。但它没有显示在网页上。我该怎么做呢?这是我的代码:
include('config.php');
//Require the db file
include('db.php');
$db = new db($dbhost, $dbuser, $dbpassword, $dbmaster);
include('function.php');
$secure = new secure();
//Get the string.
$email = $secure->clean($_GET["email"]);
if ($secure->verify_email($email) == 'false') {
echo ' <paper-dialog id="error">
<h2>Error Registering Your Account</h2>
<div>
Invalid Email!
</div>
</paper-dialog> ';
}
我为电子邮件输入了一个错误的输入:asdff,所以它会故意抛出一个错误,但是当我提交它时,当我查看网络选项卡时没有任何显示,我看到:
<paper-dialog id="error">
<h2>Error Registering Your Account</h2>
<div>
Invalid Email!
</div>
</paper-dialog>
我的实际表格代码是:
<form is="iron-form" id="formPost" method="post" action="core/register.php">
<paper-input char-counter error-message="Invalid input!" label="Username" maxlength="25" required name="username"></paper-input>
<paper-input char-counter error-message="Invalid input!" label="Display Name" maxlength="35" required name="displayname"></paper-input>
<paper-input char-counter error-message="Invalid input!" label="Password" maxlength="25" required type="password" name="password"></paper-input>
<paper-input char-counter error-message="Invalid input!" label="Confrim Password" maxlength="25" required type="password" name="cfmpassword"></paper-input>
<paper-input char-counter error-message="Invalid input!" label="Email" maxlength="25" required type="" name="email"></paper-input>
<paper-checkbox required>By checking this box, you agree that you're atleast the age of 13 or above.</paper-checkbox>
<br />
<br>
<div>
<paper-button raised
onclick="submitForm()"><iron-icon icon="check" style="margin-right:5px;"></iron-icon>Register</paper-button>
</div>
</form>
<script type="text/javascript">
function submitForm() {
document.getElementById('formPost').submit();
}
</script>
使用 iron-ajax 时如何显示错误?抱歉,如果我的问题不是那么容易理解,我真的不知道如何表达我的问题。
我发现了方法,我只需要将侦听器 iron-form-error 添加到我的 js 中。