Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7505457
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T21:55:02+00:00 2026-05-29T21:55:02+00:00

I have spent the last couple of hours battling to write some javascript and

  • 0

I have spent the last couple of hours battling to write some javascript and jquery.

Basically I am trying to loop through a table checking if an attribute exists within a TD if it does add its info into an array and post it back to the server

My code (I am sure it could be better)

      $("#save-changes").click(function () {
        var param = [];
        var table = $("#products-grid > .t-grid-content > table tbody tr").each(function (i) {
            //find checkboxes using class
            var td = ($(this).find("td:nth-child(2)").find(".cb"));
            var attr = $(td).attr('data-item');

            if (typeof attr !== 'undefined' && attr !== false) {
                console.log(td);
                param.push({ "itemId": attr, "productId": td.val() });
            }
        });
        console.log(param);

        $.ajax({
            url: '@Url.Action("ApplyProduct")',
            data:  param,
            type: 'POST',
            success: function (e) {

I am now stuck on trying to pass the array back to the server. What do I need to do to send the data back to the server as a parameter the server can understand?

Any help would be great!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T21:55:03+00:00Added an answer on May 29, 2026 at 9:55 pm

    add two parameters

    dataType: "json",
    data: JSON.stringify(param)
    

    to your .ajax call.

    Crate an object server side which has two int properties int called itemId and productId and then create a JsonResult route that takes an array of your object that you post too (this would be ApplyProduct in your case).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have spent the last 4 hours trying to get my iPad to run
Urgh, I have spent the last couple of hours on this now. I normally
I have spent the last several hours trying to get this to work and
I have spent last couple of hours searching for answers here but nothing seems
I have spent the last two days looking for a simple javascript or jquery
I have spent the last couple of days to use Core Plot for the
I have spent the last hour trying to see what I'm doing wrong, or
I have spent multiple hours trying to figure out how to pass multiple parameters
I have spent several hours trying to find a means of writing a cross
I have spent quite some time making a function and the last 15-20 minutes

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.