我使用$ http角度将表单数据发布到控制器...我想发布序列化数据..所以我正在寻求有关发布数据序列化的帮助......因为数据:$( '#main')。序列化()不工作对我来说...
demoapp.factory("authser", function ($location,$http) {
return {
login: function (credantials) {
if (credantials.username != "jot") {
alert("its ");
}
else {
// var formdata = $('#main').serialize();
//console.log(formdata);
$http({
method: 'POST',
url: "/valued/newvalue",
//responseType: "json",
data: $('#main').serialize()
//data: { 'name': credantials.username, 'password': credantials.password }
}).success(function (data) {
console.log(data);
$location.path('/logout');
});
}
},
我控制器
using angulardata.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Data.Entity;
namespace angulardata.Controllers
{
public class valuedController : Controller
{
// GET: /valued/
public ActionResult newvalue(Blog blog)
{
using (BlogContext ctx = new BlogContext())
{
Blog n = new Blog();
ctx.Blogs.Add(blog);
ctx.SaveChanges();
}
var res = new { Success = "True", Message = "Error Message" };
return Json(res,JsonRequestBehavior.AllowGet);
}
}
}
,但它不工作..任何帮助
到底是怎么回事呢?这个问题有可能因为不清楚而关闭。 stackoverflow.com/help/how-to-ask –
我编辑问题SIR @KevinBrown –