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

397
Views
Agregar lista de objetos a FormData JS

Después de agregar valores a mis paquetes de perfil e inspeccionarlo desde mi JS que contiene datos, pero en mi lado del servidor cuando presiono, ProfilePackages da como resultado un recuento = 0; incluso cuando la lista de objetos tiene datos.

Este es mi código JS

 var formData = new FormData(); formData.append("Title", $("#profileTitle").val()); formData.append("Duration", $("#txtDuration").val()); formData.append("StartingPrice", $("#startPrice").val()); formData.append("Description", $("#txtDescription").val()); formData.append("CategoryId", $("#SubCatDropDown").val()); $("#tablePackage tbody tr").each(function () { var packageDetails = {}; packageDetails.Description = $(this).find("#desc").val(); packageDetails.Amount = $(this).find("#amount").val(); packageDetails.Duration = $(this).find("#hours").val(); formData.append("ProfilePackages", JSON.stringify(packageDetails)); }); $.each($("#skills option:selected"), function (i, selected) { formData.append('ProfileSelectedSkills', selected.value); console.log(selected.value); }); $.each($('.fileUpload')[0].files, function (key, input) { formData.append('Files', input); console.log(input); }); $.ajax({ async: true, type: 'POST', dataType: 'JSON', contentType: 'application/json; charset=utf-8', data: formData, processData: false, contentType: false, url: '/F/Profile/FAddProfile?handler=SaveProfile', beforeSend: function (xhr) { xhr.setRequestHeader("MY-XSRF-TOKEN", $('input:hidden[name="__RequestVerificationToken"]').val()); }, success: function (data) { alert(data); window.location = '/F/Profile/FProfile'; // redirect }, error: function () { alert("Something went wrong"); } });

Y este es mi modelo de controlador

 public int Id { get; set; } public string Description { get; set; } public int CategoryId { get; set; } public decimal StartingPrice { get; set; } public int Duration { get; set; } public string Title { get; set; } public virtual List<ProfileSkill> ProfileSkills { get; set; } = new List<ProfileSkill>(); public virtual List<ProfileFiles> ProfileFiles { get; set; } = new List<ProfileFiles>(); public virtual List<ProfilePackage> ProfilePackages { get; set; } = new List<ProfilePackage>();

Cuando presiono, el resultado de ProfilePackges es contar = 0

over 4 years ago · Santiago Trujillo
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!