I would remove the javascript from the select element and use this script:
$(document).ready( function() {
$("body").on( "change", "#selectarea", function() {
alert("changed");
//test with alert before putting your code in here
//jQuery.ajax({
//type: "POST",
//url: "relative/path/to/disciplina.php",
//data: {dados:this.value},
//success: function(data){
//$('#novidades2').html(data);
//}
//});
});
});
Note that:
- in the ajax call I changed dados to
this.value
instead ofelement.value
. - using relative path instead of absolute path to disciplina.php
- delegation is needed for the event since
#selectarea
is generated dynamically after the dom is loaded. I used delegation from thebody
, but it may be more efficient to delegate from a closer parent element of#selectarea
.