Thread Probleme mit Ajax/jQuery (7 answers)
Opened by Kuerbis at 2011-12-22 17:59

GwenDragon
 2011-12-22 19:52
#155030 #155030
User since
2005-01-17
14533 Artikel
Admin1
[Homepage]
user image
Ich weiß nicht, was das bei dir ist, aber folgendes Testcase klappt wunderbar bei mir:

HTML:
more (6.7kb):
Code (html): (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">

<html lang="de">

        <head>
                <meta http-equiv="content-type" content="text/html; charset=utf-8">
                <title>Test AJAX, IMI and GENERAL</title>
                <style>
.done { font-size:300%; background-color:green }
.error { background-color:orange}
                </style>
                <script type="text/javascript" src="/scripts/jquery.js"></script>
        </head>

        <body>
                <script type="text/javascript">
function check (id,n) {
        switch(n) {
                case 'ok': 
                        url = 'http://labs.gwendragon.de/'; 
                        break;
                case 'nook':
                default:
                        url = 'http://labs.gwendragon.de/test/zaza0815.pl'; 
                        break;
        }
        $.ajax({
          url: url,
          context: document.body,
          success: function(){
                $(this).addClass("done");
                $(this).text('LOOK MA NO ERRORS!');
          },
          error: function(data) {
                console.log( data );
                $(this).addClass("error");
                $(this).text('MUMMYYYY!!!!! OH! NOOOO!!!! CRIED #' + data.status + ' ' +data.statusText + '#');
          }
        });
        alert(42);
}
</script>
                <button class="" onclick="check(this,'ok')">CLICK ME! and it's ok</button>
                <br>
                <button class="" onclick="check(this,'nook')">CLICK ME! BAD BOY.</button>
        </body>

</html>


CGI:
more (1.2kb):
Code (perl): (dl )
1
2
3
4
5
6
7
8
9
#!/usr/bin/perl

use strict;
use warnings;

use CGI;

print CGI::header;
die();



Editiert von GwenDragon: Url entfernt
Last edited: 2011-12-22 21:40:47 +0100 (CET)
die Drachin, Gwendolyn


Unterschiedliche Perl-Versionen auf Windows (fast wie perlbrew) • Meine Perl-Artikel

View full thread Probleme mit Ajax/jQuery