This is the fragment of code inserted with ajax:
<form>
<label for = "task-name">Name</label>
<input type = "text" id = "task-name" />
<label for = "task-description">Description</label>
<input type = "text" id = "task-description" />
<input type = "hidden" id = "task-col" />
<input type = "hidden" id = "task-row" />
<input type = "submit" id = "add-task" onclick="return false" value="Add" />
</form>
This is the JS code which insert the previous element in the DOM:
$('html').on('click', '.task-pop', function(){
var pos = $(this).parent().parent().attr('class').split("-");
ajaxObj = getXmlHttpObject();
ajaxObj.onreadystatechange = function(){
if(ajaxObj.readyState == 4 && ajaxObj.status == 200){
$('#pop-hold').html(ajaxObj.responseText);
$('#task-col').val(pos[0]);
$('#task-row').val(pos[1]);
}
};
ajaxObj.open("GET","resources/component/newTask.jsp");
ajaxObj.send(null);
$('#pop-blk').css('display','block');
$('#pop').show("fast");
});
As you can see I’m trying to add some values to the hidden inputs #task-row and #task-col from the content added dynamically.
The page is properly displayed and no error is thrown but those two fields are never accessed. How can I solve this?
change
with