By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,987 Members | 1,552 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,987 IT Pros & Developers. It's quick & easy.

Problems with window.location in confirm box

P: 1
i have created a code which post a uid to a different server on confirm dialog click and on button click it works fine the code below

for confirm box:

Expand|Select|Wrap|Line Numbers
  1. function andpop()
  2. {
  3. var qes   = confirm( " " );
  4. if ( qes )
  5. clicked( '1135' );
  6. }
  7.  
Button:
Expand|Select|Wrap|Line Numbers
  1. input type="button" value="click" onClick="return clicked('1135');">
  2.  
but i also want to redirect to another page when i click confirm or button,so i changed the code with

confirm box:
Expand|Select|Wrap|Line Numbers
  1. function andpop()
  2. {
  3. var qes   = confirm( " " );
  4. if ( qes )
  5. window.location ="buf";
  6. clicked( '1135' );
  7. }
  8.  
Button:
Expand|Select|Wrap|Line Numbers
  1. <a href="www.google.com"><input type="button" value="click" onClick="return clicked('1135');"></a>
  2.  
but now its not working it showing error

the code using for posting data:
Expand|Select|Wrap|Line Numbers
  1.         function clicked( uid ) {
  2.         $.ajax({
  3.             url:    'http://example.com/jquery/member/count.php',
  4.             type: 'GET',
  5.             data:   'uid='+uid,
  6.             dataType:   'jsonp',
  7.             jsonp:  false,
  8.             jsonpCallback:  'methodCallback',
  9.             success: function( data ) {
  10.                 if( data.message == "yes" ) {
  11.                     alert("d");
  12.                 } else {
  13.                     alert( "failed, maybe uid its not exists in database" );
  14.                 }
  15.  
  16.  
  17.             },
  18.             error: function( Request, error ) {
  19.                 alert( error );
  20.             }
  21.         });
  22.     }
  23.  
  24.  
Jun 9 '13 #1
Share this Question
Share on Google+
1 Reply


Rabbit
Expert Mod 10K+
P: 12,349
I don't understand the purpose of the AJAX call if you're going to redirect the user before the AJAX call.
Jun 10 '13 #2

Post your reply

Sign in to post your reply or Sign up for a free account.