Anup
Anup

Reputation: 9738

MVC - HttpPost issue with Ajax

I have 2 HttpPost. One is called by Json. And another is called when user submits the page.

When User clicks Delete button on page, i call DeletePhone method which deletes the records but problem is it also calls the another [HttpPost](in below code 1st one).

How to stop calling another [HttpPost]?

[HttpPost]
        public ActionResult Phones(Phones model)
        {
            ....
        }

[HttpPost]
        public JsonResult DeletePhone(int documentid)
        {
            string phoneName = Session["PhoneName"].ToString();
            bool result = settings.deletePhone(schemaName);
            return Json(result, JsonRequestBehavior.AllowGet);
        }

Upvotes: 1

Views: 53

Answers (1)

Kartikeya Khosla
Kartikeya Khosla

Reputation: 18873

I think the problem is that you are taking your delete button as input type submit that is why it is

submitting the form..Just take it as input type button..

Upvotes: 1

Related Questions