I try to implement the following code:
html
<span id = "myset">school</span>
Javascript
var myset =$("#myset").val();
var ID=$("#data li:last").attr("id");
$.get('page.php', 'id='+ID+'&set='+myset, function(newdata){
$('#data').append(newdata);
});
In the page.php file, it doesn’t receive the value of the $_GET[‘set’], but if I change
var myset =$("#myset").val();
to:
var myset ='school';
everything works fine in this case, what am I doing wrong, anyone could help me, thanks.
I also tried
var myset =document.getElementById("myset").value;
but it is still not working;
Span tags don’t have a value, they have
.innerTextor.innerHTMLor, with jQuery, .html() or .text()