tags:

views:

37

answers:

1

I'm trying to get the value of the cookie after it's been modified and pass it to a script (via http GET).

Here's my code:

<script>
function editCookieValue() {
  // function that sets/edits cookie C
}
</script>

<script type="text/javascript">
function fetchCookieValue() {
  // returns value of cookie C
}
jQuery.ajax({
   dataType: 'jsonp',
   type: 'GET',
   jsonpCallback: 'test',
   url: 'http://example.com/cgi/send?cookie='+fetchCookieValue(),
   success: function(data, status, request) {
   }
});
</script>

I want to make sure the function editCookieValue() has finished the job first before executing fetchCookieValue().

What's the best solution to accomplish this task?

A: 

Take a look at http://docs.jquery.com/AjaxQueue
It provides a sequential queue for method calls.

chriszero