Jump to content

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


fbemo

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;
   });

});

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.