Jump to content

How to close div tag automaticly?


plusnplus

Recommended Posts

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.