6
Hello, I recently ran into a problem loading div content dynamically using jQuery, but it turns out that when I upload the content to that div, I can’t recover the values that are sent from it.
The content loaded in the div is a form, which when clicked on the "add" button, it loads another function in the "onclick" event of that same button, but when I click on that button the div returns to the value set in the default of the switch and does not load the event function 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, when pressing the "Add" button, if the add() function was executed without error, a message was displayed in the div "staus" and remained on the same page instead of returning to the default page
Note: the add() function collects the data coming from the form. Part of the script that deals with this form:
produto = $('input[name=xxx]').val();
$.post('adicionar.php',{produto:produto},function(i){$('#staus').html(i)});
can give an example of html that is loaded into the div?
– Sergio
The example is available since I published the question at the end of the question.
– Edilson
Edilson, what I wanted to see is the content that you will dynamically search for. The Form and the rest of the content that is loaded.
– Sergio