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

93
Views
Ajax Sending Null Parameters to Controller

I am trying to send 3 parameters using ajax to a Controller function. My ajax looks like

$.ajax({
    url: '../saveFields',
    data: {
           fields : fieldIDs,
           values : vals,
           ID : <%= this.Model.DatabaseID %>,
    },
    success: function (data) {
           alert("Success");
    },
    error: function (data) {
           alert("Failed");
    }
});

where fieldIDs and vals are arrays populated with integers. And the Controller call is

public ActionResult saveFields(int ID, int[] fields, int[] values)

I have a breakpoint set up right before the ajax call and the first line in the Controller function. Right before the ajax call, fieldIDs and vals are correctly populated, but then the first line of the Controller function the fields and values parameters are null. ID works fine. Any assistance as to what I am doing wrong would be greatly appreciated.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Well, Jquery has different types of param serialization. Jquery Params

It turns out to fix that and pass an array correctly, you need to set the following property for the AJAX:

traditional: true
about 4 years ago · Juan Pablo Isaza Report
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!