Click here to Skip to main content
15,888,610 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
$(document).ready(function () {
//Start of the document ready function
$("#btnSave").click(function () {
debugger;
var frmData = new FormData();
var filebase = $("#fileimage").get(0);
var files = filebase.files;
frmData.append("firstname", "hi");
frmData.append(files[0].name, files[0]);
fileData.append('subTitle', subTitle.Val());
fileData.append('subStatus', subStatus.Val());
$.ajax({
url: '/ShrimpPrice/AddsubShrimpPrice',
type: "POST",
contentType: false,
processData: false,
data: frmData,
success: function (data) {
$('#myModal1').modal('show');
$('#txtMessage').html(data.message);
if (data.success) {
$('.modal-header').addClass('alert alert-success');
} else {
$('.modal-header').addClass('alert alert-info');
}
},
error: function (err) {
$('#myModal').modal('show');
$('.modal-header').addClass('alert alert-danger');
$('#txtMessage').html(err.statusText);
}
});
});

//End of the document ready function...
});









--------------------------------------------------------------------


Title - @p.Data.Title
Sub Title
Status
Y
N
Upload File
Add


What I have tried:

i Have 1 file upload ,1 dropdown and 1 textbox and i want to call on my controller using ajax post methos so please help me how to call this method-

Controller-

[HttpPost]
public ActionResult AddsubShrimpPrice(string Title, string Status)
{
{
try
{
List<cmsmobapp> obj = new List<cmsmobapp>();
MOB_APP_MAST_SHRIMPPRICELIST obj_MOB_APP_MAST_SHRIMPPRICELIST = new MOB_APP_MAST_SHRIMPPRICELIST();
obj_MOB_APP_MAST_SHRIMPPRICELIST.Title = Title;
obj_MOB_APP_MAST_SHRIMPPRICELIST.STATUS = Status;
obj_MOB_APP_MAST_SHRIMPPRICELIST.CREATED_BY = "Admin";
obj_MOB_APP_MAST_SHRIMPPRICELIST.CREATED_ON = DateTime.Now;

objen.MOB_APP_MAST_SHRIMPPRICELIST.Add(obj_MOB_APP_MAST_SHRIMPPRICELIST);
int p = 0;
p = p + objen.SaveChanges();
if (p > 0)
{
TempData["p"] = p;

}

}

catch (Exception ex)
{
Response.Write(ex.Message);
}
return RedirectToAction("ViewShrimpPriceData", "ShrimpPrice");
//return View("~/Views/Mob_App/Shrimp_Price/MOB_APP_SHRIMP_OF_LIST_PRICE.cshtml", obj_MOB_APP_MAST_SHRIMPPRICELIST.T);
}

}
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900