Reputation: 739
I wrote follwing jquery code for slider toggle box. When i execute it, jquery saying missing : after property id.
function toggleBox(){
$(".toggleLink").toggle(
function() {
$(this).parent('.toggleBoxContainer').find('.toggleBox').slideUp('slow');
var SlideStatus = $(this).parent('.toggleBoxContainer').find('.hiddenFilterID').text();
$.get(window.location ,{ $(this).parent('.toggleBoxContainer').find('.hiddenFilterID').text() : SlideStatus} );
console.log($(this).parent('.toggleBoxContainer').find('.hiddenFilterID').text());
}, function() {
$(this).parent('.toggleBoxContainer').find('.toggleBox').slideDown('slow');
$.get(window.location ,{ SlideStatus : null } );
});
}
Where i am doing wrong. Help will be greatly apprciated
Upvotes: 1
Views: 127
Reputation: 16544
Use the associative array notation for objects if you want dynamic key names
var myobject = {};
myobject[SlideStatus] = SlideStatus;
$.get(window.location, myobject);
Upvotes: 3
Reputation: 3711
Your first $.get
statement doesn't make sense. You're assigning the value of $(this).parent('.toggleBoxContainer').find('.hiddenFilterID').text()
to the variable SlideStatus
, then passing the same variable name to the $.get
statement.
Either use a different variable name outside the $.get
call, or change the name of the argument you're passing in to the $.get
call. At the moment, they're the wrong way round (it should be propertyName : propertyValue
).
Upvotes: 0