Answer the question
In order to leave comments, you need to log in
AJAX on click on area tag (html interactive maps)?
Hello! The idea is this: using the map and area tags, make image areas, by clicking on which various data will be displayed using ajax (that is, without reloading the page). Please tell me how to do it? I can't imagine at all
<div class="map">
<img src="img.png" class="map maphilighted" usemap="#simple">
</div>
<map name="simple">
<area href="a.php" shape="poly" coords="78,14,75,29,71,37,96,28" >
<area href="a.php" shape="poly" coords="73,38,50,51,50,68,43,86,54,97" >
</map>
<div id="data">Здесь выводимые данные ajax'ом</div>
Answer the question
In order to leave comments, you need to log in
Managed myself. If anyone needs:
html
<div class="map">
<img src="img.png" class="map maphilighted" usemap="#simple">
</div>
<map name="simple">
<area id="first" class="all" shape="poly" coords="78,14,75,29,71,3,20,96,28">
<area id="second" class="all" shape="poly" coords="73,38,50,4,79,118,62,105,48,95,41">
</map>
<div class="data">
</div>
$(document).ready(function(){
$('.all').click(function() {
var name = ($(this).attr('id'));
$.ajax({
url: 'a.php',
method: 'post',
dataType: 'html',
data: {name:name},
success: function(data){
$('.data').html(data);
}
});
return false;
});
});
if($_POST['name'] == 'first') {
echo 'Это первый';
} elseif($_POST['name'] == 'second') {
echo 'Это второй';
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question