Hello, I recently encountered a problem loading div contents dynamically using jQuery, but it turns out that when I load content into this div, I can not retrieve the values that are sent from it.
The content loaded in the div is a form, which when clicked the "add" button, it loads another function in the "onclick" event of that same button, but when I click that button the div returns the value set in the switch default and does not load the function of the event placed on the button.
One of the forms loaded in this div is the addition of products:
<form method="POST">
<input type="text" name="produto"/>
<input type="number" name="preco"/>
<textarea name="descricao"></textarea>
<select name="categoria">
<option value="1">1</option>
<option value="1">1</option>
</select>
<button onclick="add()">Adicionar</button>
For example, pressing the "Add" button, if the add () function was executed without error, a message would be displayed in the "staus" div and it would stay on the same page instead of returning the default page
NOTE: In the add () function, the data coming from the form is collected. Part of the script that handles this form:
produto = $('input[name=xxx]').val();
$.post('adicionar.php',{produto:produto},function(i){$('#staus').html(i)});