i am using $http in angular to post form data to controller... i want to post serialized data.. so i am seeking help about serialization of posting data... because data: $('#main').serialize() is not working for me...
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');
});
}
},
my controller
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);
}
}
}
but it is not working.. any help