Last active
October 30, 2016 21:15
-
-
Save keslo/315989dc393488126268cf62a8074c6e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $(function(){ | |
| $(document).on("submit","#myForm",function(e){ | |
| e.preventDefault(); | |
| var m_method=$(this).attr('method'); | |
| var m_action=$(this).attr('action'); | |
| var m_data=$(this).serialize(); | |
| $.ajax({ | |
| type: m_method, | |
| url: m_action, | |
| data: m_data, | |
| resetForm: 'true', | |
| success: function(result){ | |
| // Важно: создаем новый элемент | |
| var div = document.createElement('div'); | |
| /* | |
| В качестве ответа в переменную result приходит код html страницы в виде текста | |
| Чтобы можно было работать с полченным кодом как с html-узлами, | |
| необходимо поместить данный код во вновь созданный элемент, например div | |
| */ | |
| div.innerHTML = result; | |
| // Ищем в коде целой страницы блок с обновленной информацией внутри формы | |
| var response = $(div).find('#modalBody').html(); | |
| // Заменяем содержимое формы в модальном окне на полученное | |
| $("#modalBody").html(response); | |
| } | |
| }); | |
| }); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment