-2
$('#btnAfterExtraServicesSelected').die('click').live('click', function () {

   var keys = $('#extras input:checked').map(function () { return $(this).val(); }).get();
   var pets = $('#pets input:checked').map(function () { return $(this).val(); }).get();
   var selectedExtraServices = {};

     for (var i = 0, l = pets.length; i < l; i++) {
         if (pets[i]) {
            var selectedPetKeys = [];
            var name = pets[i] + '-';
            for (var j = 0, k = keys.length; j < k; j++) {
                if (keys[j].substring(0, name.length) == name) {
                     selectedPetKeys.push(keys[j].substr(name.length));
                  }
            }
   selectedExtraServices['extras-' + pets[i]] = (selectedPetKeys.join('+') || '-');
   selectedExtraServices['rextras-' + pets[i]] = null;
                        }
                    }

$('#available-rooms').load('/PetBooking/GetAvailableRoomsForTimesAndDates/', {'selectedExtraServices': selectedExtraServices }, function () {

                    });

                    return false;
                });

我需要将“selectedExtraServices”数组作为字符串传递给“load()”方法。我怎样才能做到这一点?

selectedExtraServices jQuery 对象如下:

在此处输入图像描述

4

2 回答 2

1

尝试

$('#available-rooms').load('/PetBooking/GetAvailableRoomsForTimesAndDates/', {'selectedExtraServices': JSON.stringify(selectedExtraServices) }, function () {

});
于 2013-08-05T12:55:55.283 回答
1

你为什么不使用JSON.stringify

{'selectedExtraServices': JSON.stringify(selectedExtraServices )}
于 2013-08-05T12:56:37.897 回答