0

I have on the view list of images with checkbox in front each image. Checkbox is populated with image id so I can recognize which image is checked for manipulation.

When button is clicked I'm recognizing which images are checked and store each image id to the array of ints. These array I want to sent to the mvc3 controller but I have problem I'm getting error inside sent parameters (firebug). For example if two images are checked I got following:

undefined   undefined
undefined   undefined

here's the code

var imgList = [];
$('#deleteImgBtn').click(function () {
    $('.imgCheckbox:checked').each(function () {      
        var id = $(this).attr('id');
        imgList.push(id);
    });
    jQuery.ajaxSettings.traditional = true;   
    $.ajax({
        url: '/property/deleteimages',
        type: 'POST',
        data:  imgList ,
        success: function(result){
            alert("ok");
        }
    });
...


public ActionResult DeleteImages(int[] data)
        {
            return PartialView(data);            
        }
2
  • How does your markup look like? How does the controller action you are posting to look like? There's not enough information in this question to be answered and it might be soon closed. Commented Mar 17, 2013 at 21:59
  • I'm getting null at the controller action parameter Commented Mar 17, 2013 at 22:01

1 Answer 1

1

try

$.ajax({
    url: '/Property/DeleteImages',
    type: 'POST',
    data:  { data : imgList },
    traditional : true,
    success: function(result){
        alert("ok");
    }
});
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.