1, JS part of the Code
Copy Code code as follows:
/**
* Submitting Form
*/
function SubmitForm (action, Actname, objname, Formname,blogtype) {
$ ("#" +formname). attr ("action", action);
var f = document.getelementsbytagname ("form") [0];
alert (f.action);
$ ("#" +formname). Form ({
Onsubmit:function () {
Checkinput ()//check whether the entry is empty
} ,
Success:function (data) {
if (data = = "Success") {
$.messager.alert (' Hint ', ' <br> log published successfully! ', ' info ');
}else{
$.messager.alert (' Hint ', ' <br> log publish failed! ', ' warning ');
}
}
});
}
/**
* Post Log
*/
function Publishblog () {
SubmitForm ("http://localhost:8090/webplus3/_web/sns/createBlog.do?_p=YXM9Mw__", "Publish", "Log", "FM1", "publish");
}
2, HTML part
Copy Code code as follows:
<form style= "padding:10px 8px;" method= "Post" action= "" id= "FM1" name= "FM1" >
<div style= "margin-bottom:10px;" >
<span style= "padding-right:10px;" > Title:</span>
<input type= "text" id= "title" Name= "Blog.title" class= "Int_txt" maxlength= ">"
</div>
<div style= "margin-bottom:10px;" >
<span style= "padding-right:10px;" > Content:</span>
<input type= "text" id= "content" Name= "blog.content" class= "Int_txt" maxlength= "3000" >
</div>
<button class= "Btnstyle-strong btn-submit btn-submit-2" type= "Submit" title= "Publish Log (Ctrl+enter)" id= "SaveBlogButton "Onclick=" Publishblog () >
<span> Publishing </span>
</button>
</form>