método jQuery $.ajax. éxito: función usando los datos de respuesta

Yo tengo:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>jQuery</title>
<script src="jquery-1.9.1.js"></script>
<style>

</style>
</head>
<body>
<div id="response" style="display:none"></div>

<button id="ajaxbutton">Get it!</button>
<script>
$(document).ready(function(){
    $response = $("#response");
    $button = $("#ajaxbutton");

    $button.click(function(eventObject){
        $.ajax({
            url: "ajax.php",

            type: "GET",

            datatype: "json",

            success: function(html){
                $response.fadeIn("slow").html(html);
                for(property in html)
                {
                    console.log(property) + "<br />";
                }
            }
        });
    });
});
</script>
</body>
</html>

now the jQuery part is the one I am interested in only. Especially:

success: function(html){
                    $response.fadeIn("slow").html(html);
                    for(property in html)
                    {
                        console.log(property) + "<br />";
                    }
                }

This above snippet returns the following output and I don't know why:

event.returnValue is deprecated. Please use the standard event.preventDefault() instead. jquery-1.9.1.js:3345
0 jquery.html:32
1 jquery.html:32
2 jquery.html:32
3 jquery.html:32
4 jquery.html:32
5 jquery.html:32
6 jquery.html:32
7 jquery.html:32
8 jquery.html:32
9 jquery.html:32
10 jquery.html:32
11 jquery.html:32
12 jquery.html:32
13 jquery.html:32
14 jquery.html:32
15 jquery.html:32
16 jquery.html:32
17 jquery.html:32
18 jquery.html:32
19 jquery.html:32
20 jquery.html:32
21 jquery.html:32
22 jquery.html:32
23 jquery.html:32
24 jquery.html:32
25 jquery.html:32
26 jquery.html:32
27 jquery.html:32
28 jquery.html:32
29 jquery.html:32
30 jquery.html:32
31 jquery.html:32
32 jquery.html:32
33 jquery.html:32
34 jquery.html:32
35 jquery.html:32
36 jquery.html:32
37 jquery.html:32
38 jquery.html:32
39 jquery.html:32
40 jquery.html:32
41 jquery.html:32
42 jquery.html:32
43 jquery.html:32
44 jquery.html:32
45 jquery.html:32
46 jquery.html:32
47 jquery.html:32
48 jquery.html:32
49 jquery.html:32
50 jquery.html:32
51 jquery.html:32
52 jquery.html:32
53 jquery.html:32
54 jquery.html:32
55 jquery.html:32
56 jquery.html:32
57 jquery.html:32
58 jquery.html:32
59 jquery.html:32
60 jquery.html:32
61 jquery.html:32
62 jquery.html:32
63 jquery.html:32
64 jquery.html:32
65 jquery.html:32
66 jquery.html:32
67 jquery.html:32

¿Alguien puede explicar por qué?

preguntado el 27 de noviembre de 13 a las 04:11

Can we see what is returned by your ajax.php? -

Agrega un console.log(html) -

what is ajax.php supposed to return to you? -

the php script just pints a picture -

1 Respuestas

Unfortunately I can't explain why. I'm gonna look through it a little further and see if I can't provide something for you. :) One thing I would like to say though is your jquery source is being loaded locally. I recommend using the external jquery source to load for a faster load on your page. Not sure how many people you'll have, but why not have a faster page anyways. :)

respondido 27 nov., 13:04

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.