plusnplus Posted May 31, 2010 Share Posted May 31, 2010 Hi.., I need to close a pop-up window that call from jquery. After I do update something to database inside that pop-up window, i want the window automaticly close without refresh any page. Below is how i do it: 1. a link to call the pop-up from php <a href=# title='$id' class='button' onclick=SetJsValue('$id')> 2. ajax function function SetJsValue(pass_id){ var ajaxRequest; // The variable that makes Ajax possible! try{ // Opera 8.0+, Firefox, Safari ajaxRequest = new XMLHttpRequest(); } catch (e){ // Internet Explorer Browsers try{ ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try{ ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e){ // Something went wrong alert("Your browser broke!"); return false; } } } // Create a function that will receive data sent from the server ajaxRequest.onreadystatechange = function(){ if(ajaxRequest.readyState == 4){ var ajaxDisplay = document.getElementById('ajaxDiv'); ajaxDisplay.innerHTML = ajaxRequest.responseText; var varredirect=ajaxRequest.responseText.indexOf('success'); if (varredirect!= -1 ) { window.location = "index.php" } } } var pass_id = pass_id; var queryString = "?pass_id=" + pass_id; ajaxRequest.open("GET", "customer.php" + queryString, true); ajaxRequest.send(null); } 3. body of my php page div class="popupContact"> <a class="popupContactClose">x</a><br> <div id='ajaxDiv'></div> </div> 4. pop-up java script: function loadPopup(){ //loads popup only if it is disabled if(popupStatus==0){ $(".backgroundPopup").css({ "opacity": "0.7" }); $(".backgroundPopup").fadeIn("slow"); $(".popupContact").fadeIn("slow"); popupStatus = 1; } } 5. some part of my pop-up window print "<form name='customer_form' method='POST' action='customer_update.php' target='_blank'>"; //=== some form input print "<tr><td align=right colspan=4 ><input class=Body name=button_sub type='submit' value=Update > </td></tr>\n"; print "</form>"; After i update to database, I close this new window. My question is: how to close <div id='ajaxDiv'></div> automaticly after i update user input into database? Thanks for any help/ reply *Sorry if i post in wrong forum section Link to comment https://forums.phpfreaks.com/topic/203399-how-to-close-div-tag-automaticly/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.