Jump to content

Unwanted query string in the url


Go to solution Solved by cyberRobot,

Recommended Posts

Hi guys,

 

I am using this code to open and close a pop up window, but as soon as i click the close button this

 

http://localhost/popup.php?random=&button=

 

automatically adds in the url, Please tell me what is wrong with the script

<script type="text/javascript">

 $(document).ready(function(){
    $('a.popup-window').click(function(){
       
       var popupBox = $(this).attr('href');
       $(popupBox).fadeIn(400);
	   
	   var popMargTop = ($(popupBox).height() + 24)/2;
	   var popMargLeft = ($(popupBox).width() + 24)/2;
	   
	   $(popupBox).css({
		   'margin-top' : -popMargTop,
		   'margin-left' : -popMargLeft
	   });
	   
	   $('body').append('<div id="mask"></div>');
	   $('#mask').fadeIn(400);   
	   return false;
	});
    
	$('button.close,#mask').live('click', function(){
		   $('#mask,.popupInfo').fadeOut(400,function(){
			   $('#mask').remove();
			   });	
			   return false;
			});	  	
    
       
 
 });
 $(document).keyup(function(e){
	 if(e.keyCode ==27){
		 $('#mask,.popupInfo, #popup-box').fadeOut(400);
		 return false;
		 }
	 });

 </script>
</head>

<body>
<a href="#popup-box" class="popup-window">Click</a>
  <div id="popup-box" class="popupInfo">
    <form>
      <label>ANYTHING</label></br>
      <input type="text" name="random"/></br>
      <button type="submit" name="button" class ="close">close</button>
    </form>
   </div> 

</body>
</html>
Edited by chauhanRohit
Link to comment
https://forums.phpfreaks.com/topic/289302-unwanted-query-string-in-the-url/
Share on other sites

Sorry, but changing the method to POST makes absolutely no sense.

 

The reason why you see parameters in the URL is because pressing the button submits the form. If you change the method, you're still submitting the form. The only difference is that now the parameters are sent via the message body rather than the URL. But they're still there.

 

Even worse, now the browser will issue a warning whenever you try to reload the page, because it needs to know whether it should resend the data. So, no, this is not the answer.

 

If you don't want to submit data, well, why have a form in the first place? Delete it, and the problem will go away.

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.