Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

119
Views
No se pueden enviar datos de vista desde ajax jquery al modelo o método de controlador como parámetro en dot net core mvc
$("#btnSubmit").click(function() { debugger var Pid = $("#hdnPid").val(); console.log(formdata); $("loader-area,.loader").css("display", "block"); $.ajax({ url: '@Url.Action("InsertUpdateProduct")', contentType: 'application/json; charset=utf-8', data: $('#formId').serialize(), type: 'POST', success: function(data) { debugger if (data[0].Retval = "1") { toastr.success('Record Saved Successfully.', 'Congratulations!'); } else if (data[0].Retval = "2") { toastr.success('Record Updated Successfully.', 'Congratulations!'); } else { toastr.warning('Exception Occured', 'Warning!'); } ProductMaster(); ClearData(); } - List item }); });

Controlador

 [HttpPost] public JsonResult InsertUpdateProduct(ProductMaster productMaster, IFormFile files) { List<ProductMaster> ObjProduct = new List<ProductMaster>(); try { if (ModelState.IsValid) { if (files != null) { if (files.Length > 0) { //Getting FileName var fileName = Path.GetFileName(files.FileName); //Getting file Extension var fileExtension = Path.GetExtension(fileName); // concatenating FileName + FileExtension var newFileName = String.Concat(Convert.ToString(Guid.NewGuid()), fileExtension); var objfiles = new ProductMaster() { //DocumentId = 0, ImageName = newFileName, FileType = fileExtension, // CreatedOn = DateTime.Now }; using(var target = new MemoryStream()) { files.CopyTo(target); objfiles.Image = target.ToArray(); productMaster.Image = objfiles.Image; } } } //productMaster.PID = PID; objProductData.InsertUpdateProduct(productMaster); if (productMaster.PID == 0) { _notyf.Success("Record Saved Successfully"); } else { _notyf.Success("Record Updated Successfully"); } } else { _notyf.Warning("Model false display"); } } catch (Exception ex) { _notyf.Error("Error Occured"); } return Json(ObjProduct); }
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!