我有一个关联数组,我试图将它传递给jquery载入方法的参数部分。但是它并没有在服务器端显示为帖子。我怎样才能做到这一点?jquery ajax使用负载传递信息
这里是我的代码:
var selectcustomerpopup = null;
$(document).ready(function() {
// Find customer
$('.CustomerSelectBtn').click(function() {
var uniqueid = $(this).attr('id');
var customerSelectURL = $('#ajax_customer_select_url').val()
+ "/" + uniqueid;
var custselectdata = new Array();
custselectdata["fname"] = "TestFirst";
custselectdata["lname"] = "TestLast";
if (! ($('#selectCustomerDialog').length)) {
$('body').append(
$('<div id="selectCustomerDialog" style="display: none;"></div>')
);
}
var $findCustomerDialog =
$('#selectCustomerDialog').load
(customerSelectURL, custselectdata)
.dialog({
autoOpen: false,
title: 'Select Customer',
width: 630,
height: 450,
position: 'center',
resizeable: true,
modal: true,
draggable: true,
closeOnEscape: true,
closeText: 'close'
});
$findCustomerDialog.dialog('open');
selectcustomerpopup = $findCustomerDialog;
return false;
});
});
附加信息: 我有一个很好的答案,但我做了一些调查研究,并发现了一个伟大的链接解释JavaScript的关联数组非常好:http://blog.xkoder.com/2008/07/10/javascript-associative-arrays-demystified/
我想你只需要一个对象来代替'custselectdata'数组:'VAR custselectdata = {};' – Blazemonger
mblase,你有正确的答案,更换使用{}使其成为对象的数组是可行的解决方案,但没有答案让我选择。 – stephenbayer