[英]Polymer Iron-Form Output Error
I'm new to Polymer, and I'm using the iron-form component to submit a to the database. 我是Polymer的新手,并且正在使用Iron-form组件将a提交到数据库。 My question is how would I be able to report an error back out to iron-form and to the html?
我的问题是如何将错误报告回铁表格和html? I have tried using php
echo
and return it through a json array. 我尝试使用php
echo
并通过json数组返回它。 but it did not show on the webpage. 但它没有显示在网页上。 How would I go about doing this?
我将如何去做呢? here is my code:
这是我的代码:
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> ';
}
I have put in a wrong input for the email which is: asdff, so that it would purposely throw an error, but when I submit it, nothing shows when I look in the network tab, I see: 我为该电子邮件输入了错误的输入:asdff,以便有意引发错误,但是当我提交该错误时,在“网络”标签中查看时没有任何显示。
<paper-dialog id="error">
<h2>Error Registering Your Account</h2>
<div>
Invalid Email!
</div>
</paper-dialog>
My code for the actual form is: 我的实际形式的代码是:
<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>
How would I go about showing the errors when using iron-ajax? 使用Iron-ajax时如何显示错误? Sorry if my question isn't that understandable I really didn't know how to word my question.
抱歉,如果我的问题不是那么容易理解,我真的不知道该怎么表达我的问题。
我发现了如何,我只需要在我的js中添加侦听器iron-form-error。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.