Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $j.ajax({
- type: "POST",
- url: "/Services/Cart.asmx/UpdateQuantity",
- data: data,
- contentType: "application/json; charset=utf-8",
- dataType: "json",
- success: function(msg) {
- var d = msg.d;
- // etc.
- },
- error: function(xhr, msg) {
- var response = JSON.parse(xhr.responseText);
- var cart = $j('#cart');
- if (response.Message) {
- cart.before(' <div class="error">' + response.Message + '</div> ');
- }
- else {
- cart.before(' <div class="error">An unexpected error occurred.</div> ');
- }
- },
- complete: function(request, settings) {
- // Some other stuff.
- }
- }); // end ajax
- alert('Initially thought this would be called after above .ajax call complete. But it is not. Rather, it is called before success etc.')
- $j.ajax({
- type: "POST",
- url: "/Services/Cart.asmx/UpdateQuantity",
- data: data,
- contentType: "application/json; charset=utf-8",
- dataType: "json",
- success: newSuccessFunction(xhr,msg),
- error: function(xhr, msg) {
- var response = JSON.parse(xhr.responseText);
- var cart = $j('#cart');
- if (response.Message) {
- cart.before(' <div class="error">' + response.Message + '</div> ');
- }
- else {
- cart.before(' <div class="error">An unexpected error occurred.</div> ');
- }
- },
- complete: function(request, settings) {
- // Some other stuff.
- }
- }); // end ajax
- function newSuccessFunction(xhr,msg) {
- var d = msg.d;
- //... etc.
- $.ajax({ //...
- });
- alert('Initially thought this would be called after above .ajax call complete. But it is not. Rather, it is called before success etc.')
- }
Add Comment
Please, Sign In to add comment