I have two windows. Parent ( Main.aspx ) and Child.aspx ( Child.aspx ). From the child window I send post data and after receiving the answer I want to work with the element in the parent content.
I got access to the item through
$(window.opener.document).find("#element"); But I ran into another problem, after answering the server as json data I need to close the child window ..
window.close() the window is closed but after that the control over the element is immediately lost.
$("#btn").click(function () { var m = confirm("Вы уверены что хотите удалить данную запись пользователя? Данные будут удалены безвозвратно."); if (m) { var Username = $("#FieldUsername").val(); var elem = $(window.opener.document).find("#SysMessage"); $.ajax({ url: "Child.aspx/Delete", datatype: "json", cache: false, async: true, contentType: "application/json; charset=utf-8", method: "POST", data: JSON.stringify({ 'Username': Username }), beforeSend: function () { elem.stop().fadeOut(); }, complete: function () { }, success: function (data) { console.log(data.d); data = JSON.parse(data.d); if (data.type == "error") { elem.addClass("error"); } else { $(window.opener.document).find("#__Refresh").click(); elem.addClass("success"); } elem.text(data.str); elem.slideToggle('medium'); elem.delay(5000).fadeOut(800); window.close(); } }); And the window closes immediately, although it should last. Tell me what my misunderstanding is, how to be.
var elem = window.opener.$(document).find("#SysMessage");- Igoralert(elem.length);aftervar elem = ...- Igor