Link to home
Start Free TrialLog in
Avatar of Coast Line
Coast LineFlag for Canada

asked on

jquery ajax functionality to respond to internal post and load the data accordingly

Modifying the JS Code to work one by one and based upon inside ajax post, it should process the activation

Here is the code i have

$.post('/cfc/mycfc.cfc?method=stop', {id: id}, function(data) {
			if(data.status == 1) {
				return $.post('/register.html?action=remove' {id: id, pid: $('body').attr('data-pid')},callback,'json');
				swal('',data.statusmsg,'success'); - i want to get this inside the second post so it should work properly and trying to make use of async as by using ajax so they get called one by one 
				CheckPause(data);
				$('#wrapper').load( "#Pause");
			}else {
				swal('',data.statusmsg,'error');
			}
		},'json')

Open in new window

Avatar of Julian Hansen
Julian Hansen
Flag of South Africa image

It is not clear what you are asking.

Why are you doing a return on line 3 - that is going to ensure that lines 4-6 never fire?
Avatar of Coast Line

ASKER

modified like this:

$.ajax(type:'POST',url:'/cfc/mycfc.cfc?method=Pause', data: {id : id}, async: false, success: function(data) {
			if(data.status == 1) {
				$.post('/register.html?action=Rremove' {id : id, pid : $('body').attr('data-pid')},function(_data) {
					if(_data.status == 1) {
						swal('',data.statusmsg,'success');	
					}
				});
				CheckPause(data);
				$('#wrapper').load( "#Pause");
			}else {
				swal('',data.statusmsg,'error');
			}
		})

Open in new window


they is a change i would like to make,

1. i want to use the error handling on the first one and if it occurs say _data.status = 0, it should never execute the others, same is the case for the data one, and basically enhance the code to better technique

Thanks
ASKER CERTIFIED SOLUTION
Avatar of Julian Hansen
Julian Hansen
Flag of South Africa image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial