Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var texts = {
- validate : 'Verifierar...',
- proceed : 'Fortsätter',
- ajax_error : 'apa',
- back_warning: 'kuk'
- };
- $('form').submit(function() {
- var form = $(this);
- var navi = form.find('a.next,a.prev');
- var proc = form.find('div.processor');
- form.find('.alert').hide().html('');
- navi.hide();
- proc.html(texts.validate).show();
- // If external processing then send form
- if($(this).find('input[name=external_processing]').length) { return true; }
- var details = $(this).serialize();
- var url = $(this).attr('action');
- $.ajax({ url: url, type: "post", dataType: "json", data: details + "&json=1", timeout: 10000,
- error: function(req, status, error) { proc.hide(); navi.show(); alert(texts.ajax_error); },
- success: function(data) {
- if(data.error) {
- proc.hide();
- navi.show();
- $.each(data.error, function(field, messages) {
- $('#'+field).find('div.alert').html("");
- $.each(messages, function(key, message) {
- if($('#'+field).find('div.alert').length) {
- $('#'+field).find('div.alert').append(message + "<br />").show();
- }else{
- alert(message);
- }
- });
- });
- }
- if(data.ready == true) {
- proc.html(texts.proceed);
- window.location = data.proceed;
- }
- }/*,
- complete: function(XML, status) {
- if(status != "success") {
- proc.hide();
- navi.show();
- }
- }*/
- });
- return false;
- });
Add Comment
Please, Sign In to add comment