Jump to content

How to Stop whole script or Jump to function such as GoTo


Recommended Posts

Hello,

Below is my script;

 

$(document).ready(function(){

$('form input').hover(function(){
	$(this).addClass('input_hover');
}, function(){
	$(this).removeClass('input_hover');
});

$('form input').focus(function(){
	if($(this).val() == 'http://')
		$(this).val('');
});

$('button').click(function(){

	if($('form input[@type="text"]').val() == '')
		return false;

	$(this).attr('disabled', true);
	$('#link').hide();
	$('#processing').show();

	$.post("ajax.php", 
	{
	 'a' : 'make_short', 
	 'url' : $('form input[@name="url"]').val(),
	 'tag' : $('form input[@name="tag"]').val(),
	 'ip' : $('form input[@type="hidden"]').val()
	},
	 function(data){

		if(data == 'invalid'){

			$('#processing').hide();
			$('button').attr('disabled', false);
			alert('Invalid Url');

			return false;
		}
		if(data.search(/^error/) != -1)
		{
			var datap = data.split('::');

			if(datap[1] == '0001')
			{
				$('#processing').hide();
				$('button').attr('disabled', false);

				alert('Custom Tag may contain letters, numbers and dashes');
				return false;					
			}
			if(datap[1].search(/^0002/) != -1)
			{
				alert('Chosen Custom Tag is already in use. aaa');
				<!--	I Want the Script STOP here or jump to any function that will Stop the whole SCRIPT without executing the code below $('#processing').hide();........... -->

			}				

		}

		$('#processing').hide();

		$('#link span').html('<a href="' + data + '" target="_blank">' +
				data + '</a>'
		).parent().show();

		$('button').attr('disabled', false);
		return false;		
	 });

	return false;
});

});

 

You can found this inside the code:

<!-- I Want the Script STOP here or jump to any function that will Stop the whole SCRIPT without executing the code below $('#processing').hide();........... -->

 

I want to stop the whole script if if(datap[1].search(/^0002/) != -1) without executing the next whole lines... (Means nothing will be happening, nothing will be executed).

 

 

Thanks a lot :D

 

Maybe I'm missing something obvious but couldn't you just return at that point?

 

Sorry, I don't get it...

 

Btw, if you look into that coding... there is a function(data);..

 

I want to create another function similar to that but won't passing these codes (see below) when it reads this statement if(datap[1].search(/^0002/) != -1)

 

$('#processing').hide();

         $('#link span').html('<a href="' + data + '" target="_blank">' +
               data + '</a>'
         ).parent().show();
         
         $('button').attr('disabled', false);
         return false;      
       });

      return false;
   });

});

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.