jQuery: The Write Less, Do More JavaScript Library

ajax: don't read the html reply

View: New views
1 Messages — Rating Filter:   Alert me  

ajax: don't read the html reply

by HeNdRiX-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Hello all, sorry for my bad english.
I have a problem whit the jquery ajax;

I have this test page whit the jquery javascript:

<!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=iso-8859-1" />
        <title> Jquery test </title>
        <link rel="stylesheet" type="text/css" href="/style.css" /
>
        <script type="text/javascript" src="/js-fwk/jquery.js"></
script>
        <script type="text/javascript">

            var htmlupd = '';

            function onStartLoading() {
                alert('onStartLoading');
            }
            function onSuccess(msg) {
                $("#contenuti").remove();
                htmlupd = msg;
                $("#udt").html(htmlupd);
            }
            function onError(xhr, st, er) {
                alert(er);
            }
            function ajaxInit(){
                    $.ajaxSetup({
                        url : 'test.php',
                        type : "POST",
                        dataType : "html",
                        beforeSend : onStartLoading,
                        success: onSuccess,
                        error : onError
                    });
                    $.ajax({  data: "nameCat=prova" } );
            }
            $(document).ready( function () {

                $('#sendr').click(function() {
                    ajaxInit();
                    return false;
                });

            });
        </script>
    </head>
    <body>
        <div id="udt">
            <div id="contenuti">
            da richiedere...
            <button id="sendr">UPDATE</button>
            </div>
        </div>
    </body>
</html>


And the simple test page test.php

<?php
echo '
    <div id="contenuti">
    Richiesta:  '.$nameCat.'
    <button id="sendr">UPDATE</button>
    </div>
    ';
?>

when i send the ajax request the div is update but if i click in the
button of the loaded html it don't work

why not see the html loaded from the test.php?

why not run the javascript of the remote page?