Created
October 30, 2016 21:14
-
-
Save keslo/296e52e68d001aa3ef396ba410d8aa33 to your computer and use it in GitHub Desktop.
modx_evo_form_modal
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