This article introduces an example code of jquery ajax submitting form items. I hope this tutorial will be helpful to you.
| The Code is as follows: |
Copy code |
$ ("Form [name = 'createbox']"). submit (function (){
Var self = this;
$. Post ("/index. php? Action = ajax & rs = TWProAjax: checkProTermsExisted ", $ (this). serialize (), function (data ){
If (data & data. length> 0 ){
Var sTitle = "Some terms have been existed with the same name ";
Var aContent = [];
For (var I = 0, len = data. length; I <len; I ++ ){
Var term = data [I];
Var sTerm = '<a href = "' + term. ns_text + ':' + term. pagename + '"target =" _ blank ">' + term. term + '<a/> ';
If (term. industry ){
STerm + = '(';
STerm + = 'industry: '+ term. Industry;
STerm + = term. category? '; Product Category:' + term. category :'';
STerm + = ')';
}
AContent. push (sTerm + '<br/> ');
}
Var sContent = '<p> There are some terms with the same name you inputed. </p> ';
SContent + = aContent. join ('');
SContent + = '<p> Do you confirm to create a new one? </P> ';
ShowDialogProTermsExisted (sTitle, sContent );
} Else {
Self. submit ();
}
}, 'Json ');
Return false;
}); |