Today it took almost a day to do the form of the value and save to the database, display, as a small progress of their own, notes down, look more.
is similar to the post message feature:
Front Code:
<div id= "Dialog" class= "animated" >
<div class= "Dialogtop" >
<span style= "Float:left; Color: #808080; " > Questions </span>
<a href= "javascript:;" class= "clasedialogbtn" > Close </a>
</div>
<form action= "" method= "Post" id= "EditForm" name= "AddForm" >
<ul class= "Editinfos" style= "padding:0px;" >
<li><input type= "text" name= "nickname" id= "Nick" style= "width:90%;height:30px;border:1px solid RGB (169, 169, 169); BORDER-RADIUS:4PX, "placeholder=" Please enter the name "/></li> "
<li><textarea style= "width:90%;height:100px; border-radius:4px;" Placeholder= "Please enter your question ~" id= "Questxt" Name= "Question" ></textarea></li>
<li><input type= "Submit" value= "Confirm Submit" class= "submitbtn" id= "AddMessage"/></li>
</ul>
</form>
</div>
Color labeling is the main code ...
Ajax:
<script>
$ (' #AddMessage '). Click (function () {
var name = $ (' #nick '). Val ();
var question = $ (' #questxt '). Val ();
$.ajax ({
Type: "POST",
URL: '/default/addmessage ',
Cache:true,
Async:false,
Data: {
Quizzer:name,
Question:question,
},
Success:function (data) {
Alert ("Submit success!");
},
Error:function () {
Alert (' Submit failed! ‘);
}
});
});
</script>
The following is the code inside the C # MVC controller:
<summary>
Release
</summary>
<param name= "Id" ></param>
<param name= "Quizzer" > Nickname </param>
<param name= "Question" > Questions </param>
<param name= "Questiontime" > Message time </param>
<returns></returns>
[HttpPost]
public void AddMessage (String quizzer,string Question)
{
QandA QandA = new QandA ();
QandA. Quizzer = Quizzer;
QandA. Question = Question;
QandA. Questiontime = DateTime.Now;
Db. Qandas.add (QandA);
Db. SaveChanges ();
}
I hope I will make more progress in the future.
Ajax commits the presentation of data to the background