Guest User

Untitled

a guest
May 24th, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.45 KB | None | 0 0
  1. var texts = {
  2. validate : 'Verifierar...',
  3. proceed : 'Fortsätter',
  4. ajax_error : 'apa',
  5. back_warning: 'kuk'
  6. };
  7.  
  8. $('form').submit(function() {
  9. var form = $(this);
  10. var navi = form.find('a.next,a.prev');
  11. var proc = form.find('div.processor');
  12. form.find('.alert').hide().html('');
  13.  
  14. navi.hide();
  15. proc.html(texts.validate).show();
  16.  
  17. // If external processing then send form
  18. if($(this).find('input[name=external_processing]').length) { return true; }
  19.  
  20. var details = $(this).serialize();
  21. var url = $(this).attr('action');
  22. $.ajax({ url: url, type: "post", dataType: "json", data: details + "&json=1", timeout: 10000,
  23. error: function(req, status, error) { proc.hide(); navi.show(); alert(texts.ajax_error); },
  24. success: function(data) {
  25. if(data.error) {
  26. proc.hide();
  27. navi.show();
  28. $.each(data.error, function(field, messages) {
  29. $('#'+field).find('div.alert').html("");
  30. $.each(messages, function(key, message) {
  31. if($('#'+field).find('div.alert').length) {
  32. $('#'+field).find('div.alert').append(message + "<br />").show();
  33. }else{
  34. alert(message);
  35. }
  36. });
  37. });
  38. }
  39.  
  40. if(data.ready == true) {
  41. proc.html(texts.proceed);
  42. window.location = data.proceed;
  43. }
  44. }/*,
  45. complete: function(XML, status) {
  46. if(status != "success") {
  47. proc.hide();
  48. navi.show();
  49.  
  50. }
  51. }*/
  52.  
  53. });
  54.  
  55. return false;
  56. });
Add Comment
Please, Sign In to add comment