function register() {
var jsObj = {};
var data = $('#register').serializeArray();
$.each(data,function(index,feild){
jsObj[feild.name] = feild.value;
console.log(feild.name+" -- "+feild.value);
});
$.ajax({
url: '/Signup/Registeration',
type: 'POST',
contentType: "application/json; charset=utf-8",
dataType: "json",
data: JSON.stringify(jsObj),//this is my data in json format
async: false,
success: function (data) {
alert(data);
}
});
}
这是我的控制器动作方法
[HttpPost]
public JsonResult Registeration(SignUp data)
{
return Json(data);
}
这是我的注册课程
public class SignUp
{
public string username { get; set; }
public string password { get; set; }
public string cpassword { get; set; }
}