I have a problem when i try to grab the value from a div in my html string. Maybe someone here could find the problem for me.
I have tried a lot of different ways to take the data out. Solutions that works for others don't work for me at all. So i think i am doing something seriously wrong
$(document).ready(function () {
var id = 1;
function updateMsg() {
$.ajax({
url: "/opt/history/update?current=" + 1,
cache: false,
success: function (html) {
id = $(html).find('#last').html();
console.log('ID: ' + id);
$("#result").html(html);
}
});
setTimeout(updateMsg, 5000);
}
updateMsg();
});
This is how the div looks like
<div id="last" style="display: none;">2</div>
There is a bunch of html code before this div. This div will always be at the bottom of the html string.
Update: The thing is. I need to transport the value of a id in this html string but not show it visually. If you have a better way that i should look at.
The HTML output on success
<tr>
<td>2014-07-08 14:35:47.456</td>
<td>123</td><td>321</td>
<td>Has data</td>
<td><a data-toggle="modal" data-request="2014-07-08 14:35:47.456" data-mobile="123" data-check="321" data-log="Has latest update" data-context="Context" data-historyid="28" title="info" class="open-logInfo btn btn-default" href="#logInfo">
<i class="icon-info-sign icon-black"></i> Info </a>
</td>
</tr>
<div id="last" style="display: none;">28</div>
I have a problem when i try to grab the value from a div in my html string.What's the problem?console.log( html )in the success callback.