usergeyv
Знаток
- Регистрация
- 5 Июл 2013
- Сообщения
- 152
- Реакции
- 25
- Автор темы
- #1
html
делаю
Отрабатывает только первое значения то есть "12",как обработать все значения на странице?
HTML:
<div id="test" data-id="12">
<div id="test" data-id="123">
<div id="test" data-id="1234">
<div id="test" data-id="12345">
<div id="12"></div>
<div id="123"></div>
<div id="1234"></div>
<div id="1234"></div>
HTML:
jQuery(function(){
var theId = $('#test').data("id");
$.ajax({
url: url,
type: "POST",
dataType: "html",
data: {news: theId},
success: function(response) {
result = $.parseJSON(response);
if (result.status == 'ERROR') {
$('#'+theId).html('<a href="http://site.ru/404" target="_blank"></a>');
} else if (result.status == 'OK') {
$('#'+theId).html('<a href="http://site.ru/' + result.id_news +'" target="_blank"></a>');
}
},
error: function(response) {
$('#'+theId).html('<a href="http://site.ru/404" target="_blank"></a>');
}
});
});