У меня есть форма в AJAX
, но когда у меня есть несколько форм на одной странице, появляется ошибка.ajax form submit без ошибки обновления
<script>
var fmx = jQuery.noConflict();
fmx(document).ready(function(){
fmx('form').on('submit', function (e) {
e.preventDefault();
fmx.ajax({
type: 'post',
url: 'https://www.webshop.com/post.php',
data: fmx('form').serialize(),
success: function() {
document.getElementById('#form_post').style.display = 'none';
document.getElementById('#form_result').style.display = '';
}
});
});
});
</script>
<div id="#form_post" style="display:inherit">
<form class="form_post">
<label for="post_email">FORM</label>
<input id="post_email" class="post_email" type="email" name="post_email" placeholder="[email protected]" required>
<input id="post_data" class="post_data" type="text" name="post_data" placeholder="MSG" required>
<input name="submit" type="submit" value="POST" >
</form>
</div>
<div id="#form_result" style="display:none"><br>Success.</div>
Я попытался переключиться на #id, но он перестал работать.
<script>
var fmx = jQuery.noConflict();
fmx(document).ready(function(){
fmx('#form').on('submit', function (e) {
e.preventDefault();
fmx.ajax({
type: 'post',
url: 'https://www.webshop.com/post.php',
data: fmx('#form').serialize(),
success: function() {
document.getElementById('#form_post').style.display = 'none';
document.getElementById('#form_result').style.display = '';
}
});
});
});
</script>
<form class="form_post" id="form">
Как делать положить ID
в этой форме?
Какая ошибка у вас? – SLaks
Идентификаторы должны быть уникальными. – SLaks
Приложение HTML не имеет идентификатора в форме – Jonathan