0
私のAPIでユーザーデータを送信しようとしていますが、このフォームではエラーメッセージと正常なmessage.soを印刷しようとしていますが、フォーム提出後のメッセージ。エラーメッセージと成功したメッセージを登録フォームに設定する方法
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<link rel="stylesheet" type="text/css" href="styles.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<!-- Optional theme -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css" integrity="sha384-rHyoN1iRsVXV4nD0JutlnGaslCJuC7uwjduW9SVrLvRYooPp2bWYgmgJQIXwl/Sp" crossorigin="anonymous">
<!-- Latest compiled and minified JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
<script type="text/javascript">
$(document).ready(function() {
$("#Save").click(function() {
// var person = new Object();
// person.Title = $('#Title').val();
// person.FirstName = $('#FirstName').val();
// person.LastName = $('#LastName').val();
// person.CompnayName = $('#CompnayName').val();
// person.Address = $('#Address').val();
// person.Email= $('#Email').val();
// person.Phone = $('#Phone').val();
// person.Mobile = $('#Mobile').val();
debugger;
var person=$('#form1').serialize();
$.ajax({
url: 'http://192.168.1.102:1512/qlikapi/RegisterUser',
type: 'Post',
data:person,
success: function (data, textStatus, xhr) {
console.log(data.ErrorMessage);
},
error: function (xhr, textStatus, errorThrown) {
console.log('Error in Operation');
}
});
});
});
</script>
<style>
textarea:focus, input:focus{
outline: 0;
}
input:focus:invalid,
textarea:focus:invalid{
border:1px solid #F5192F;
box-shadow:0 0 4px #F5192F;
}
input:focus:valid,
textarea:focus:valid{
border: 1px solid #64C364;
box-shadow: 0 0 4px #64C364;
}
</style>
</head>
<body>
<div class="container">
<div class="row">
<form id="form1" method="post">
<div class="form-title-row">
<h1>Register Here</h1>
</div>
<div class="col-md-6">
<div class="form-row">
<label>
<span> Title </span>
<input type="text" name="Title" id="title"required>
</label>
</div>
<div class="form-row">
<label>
<span> FirstName </span>
<input type="text" name="FirstName" id="lastname"required>
</label>
</div>
<div class="form-row">
<label>
<span> Address </span>
<input type="text" name="Address" id="address"required>
</label>
</div>
<div class="form-row">
<label>
<span> Phone</span>
<input type="text" name="Phone" id="phone"required>
</label>
</div>
</div><!--closed fo first form<!-->
<div class="col-md-6">
<div class="form-row">
<label>
<span> LastName </span>
<input type="text" name="LastName" id="lastname"required>
</label>
</div>
<div class="form-row">
<label>
<span>Email</span>
<input type="email" name="Email" required pattern="^\[email protected]\S+\.\S+$" title="[email protected]">
</label>
</div>
<div class="form-row">
<label>
<span> CompanyName </span>
<input type="text" name="CompanyName" id="compnayname"required>
</label>
</div>
<div class="form-row">
<label>
<span> Mobile </span>
<input type="text" name="Mobile" id="Mobile"required>
</label>
</div>
<div class="form-row">
<button type="submit" id="Save">Submit Form</button>
</div>
</div>
</form>
</div><!-- closed for row><!-->
</div><!--closed for container><!-->
</body>
</html>
- これを設定します。
balu、@@あなたが後にボタン –
を提出し、アラートを作成する方法を教えてくださいすることができますhttps://scotch.io/tutorials/submitting-ajax-forms-with-jquery –