Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision b9740e8a

Von Moritz Bunkus vor mehr als 11 Jahren hinzugefügt

  • ID b9740e8a9a77eafcaf7aacd530af23fa8dbcb9f9
  • Vorgänger de66b95f
  • Nachfolger 001c83b1

Error-Handling: Bei AJAX-Requests Fehler als JSON-Object zurückgeben

Unterschiede anzeigen:

js/client_js.js
4 4
// "scripts/generate_client_js_actions.pl". See the documentation for
5 5
// SL/ClientJS.pm for instructions.
6 6

  
7
function display_flash(type, message) {
8
  $('#flash_' + type + '_content').text(message);
9
  $('#flash_' + type).show();
10
}
11

  
7 12
function eval_json_result(data) {
8 13
  if (!data)
9 14
    return;
10 15

  
16
  if (data.error)
17
    return display_flash('error', data.error);
18

  
19
  $('#flash_error').hide();
20
  $('#flash_error_content').empty();
21

  
11 22
  if ((data.js || '') != '')
12 23
    eval(data.js);
13 24

  
......
15 26
    $(data.eval_actions).each(function(idx, action) {
16 27
      // console.log("ACTION " + action[0] + " ON " + action[1]);
17 28

  
29
      // ## Non-jQuery methods ##
30
           if (action[0] == 'flash')                display_flash(action[1], action[2]);
31

  
18 32
      // ## jQuery basics ##
33

  
19 34
      // Basic effects
20
           if (action[0] == 'hide')                 $(action[1]).hide();
35
      else if (action[0] == 'hide')                 $(action[1]).hide();
21 36
      else if (action[0] == 'show')                 $(action[1]).show();
22 37
      else if (action[0] == 'toggle')               $(action[1]).toggle();
23 38

  
......
94 109

  
95 110
  // console.log("current_content_type " + $('#current_content_type').val() + ' ID ' + $('#current_content_id').val());
96 111
}
112

  
113
// Local Variables:
114
// mode: js
115
// End:

Auch abrufbar als: Unified diff