peps03
asked on
Trigger ajax-call by clicking div
Hi,
I have 9 divs, if one is clicked an ajax-call should be triggered, sending the number 1-9 (corresponding with the number of the div) to the call. The ajax works fine, but i can't get it to fire when a div is clicked.
How should i do this? The methods i tried don't work.
Thanks
I have 9 divs, if one is clicked an ajax-call should be triggered, sending the number 1-9 (corresponding with the number of the div) to the call. The ajax works fine, but i can't get it to fire when a div is clicked.
How should i do this? The methods i tried don't work.
Thanks
ASKER
$("#thumbpic1").click(func tion() {$('#playpp').trigger('cli ck'); thumb = 1;});
if(thumb == 1 || thumb == 2 || thumb == 3 || thumb == 4 || thumb == 5 || thumb == 6 || thumb == 7 || thumb == 8 || thumb == 9){
$.ajax({
type: "POST",
data: "album=" + thumb,
url: "getselect.php",
success: function(msg){
if (msg != ''){
$("#gallery1").html(msg);
}
else{
// Some error handling in case nothing is returned
$("#gallery1").html('Error ..').show( );
}
}
}); // close ajax
};
if(thumb == 1 || thumb == 2 || thumb == 3 || thumb == 4 || thumb == 5 || thumb == 6 || thumb == 7 || thumb == 8 || thumb == 9){
$.ajax({
type: "POST",
data: "album=" + thumb,
url: "getselect.php",
success: function(msg){
if (msg != ''){
$("#gallery1").html(msg);
}
else{
// Some error handling in case nothing is returned
$("#gallery1").html('Error
}
}
}); // close ajax
};
$("#thumbpic1").click(func tion() {$('#playpp').trigger('cli ck'); thumb = 1;});
so whats you css
so whats you css
ASKER
why you need to know any css?
this function show work right? or does it contain errors?
this function show work right? or does it contain errors?
#thumbpic1 is the target for the click event
ASKER
no.. the source. #thumbpic1 is the id of the div being clicked.
yes ie target but you have multiple divs so shouldn't the target be a container around the 9 divs
ASKER
don't mind that. say i have 1 div, if it is clicked, 'var thumb' must become 1, and the ajax call triggered, how should i do that?
thats all, if i trigger the ajax call manually, it works.
thats all, if i trigger the ajax call manually, it works.
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER
Thank you ChrisStanyon!
That did the trick!
That did the trick!
you need an on-click JavaScript event in the div