Reputation: 5039
I have a javascript function ...
function check_val(name, cat)
{
alert(cat);
var val = name.indexOf('[');
if (val == -1){
//$('input[type="checkbox"][value='+ name + ']')[0].click()
val = '"' + name + '"'
type = "'" + cat + "'"
$.get(url,{'ajaxtype':'content', type : val}, function(data{$('#search_container').html(data);$('#rotator').hide();});
}
}
when i call this function with argument say check_val('xyz','pqr')
The problem is when I check the request.get parameter I am getting
<QueryDict: {u'type': [u'"xyz"'], u'ajaxtype': [u'content']}>
instead of
<QueryDict: {u'pqr': [u'"xyz"'], u'ajaxtype': [u'content']}>
Upvotes: 0
Views: 58
Reputation: 265668
Build the object beforehand and use array subscript syntax:
var requestData = { 'ajaxtype': 'content' };
requestData[type] = val;
$.get(url, requestData,
function(data{$('#search_container').html(data);$('#rotator').hide();});
Upvotes: 1
Reputation: 9775
Instead of {'ajaxtype':'content', type : val}
try {'ajaxtype':'content', "'" + cat + "'" : val}
.
This way JS should know that it's not key name but variable.
Upvotes: 0