前端之家收集整理的这篇文章主要介绍了
二种ajax,
前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
1.
- $.ajax({
- type:"post",dataTyep:"json",async: false,//取消异步
- url:"check_username.jspx",data:{
- username:username
- },success : function(result) {
- if (result.result == 0) {
- $("#uName").show();
- $("#uName").html("用户名已经使用");
- flag = false
- } else {
- $("#uName").hide();
- flag = true
- }
- }
- })
2.
- $.post($("#registform").attr("action"),$("#registform").serialize(),function(result) {
- if(result.success) {
- layer.msg("注册成功!");
- setInterval("window.location.href = '/';",1000);
- return ;
- }
- layer.msg("注册失败!" + result.FailedMessage);
- });