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

400
Views
Appending List of Object to FormData JS

After Adding values to my profile packages and inspecting it from my JS that it has data contained in it, but on my server side when i push, ProfilePackages results to count = 0; even when Object List has Data.

This is my JS Code

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");
        }
    });

And this is my Controler Model

 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>();

When i push, ProfilePackges result to count = 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!