views:

63

answers:

1

I'm having quite a frustrating problem that I'm sure is TRIVIAL. Whenever I move this jQuery post inside the click function it sometimes works, but most of the time does not. If I move it outside it works and posts and gives a response like it should everytime..

::boggled:: Someone please enlighten me.

         $(document).ready(function() {
         $('#Button1').click(function() {

        //alert(document.getElementById('TextBox1').value);
        $.ajax({
            type: "POST",
            url: "sudoku.asmx/getSolution",
            data: "{'pid':'34367'}",
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            success: function(msg) {
                alert("succes " + msg.d);
            },
            error: function(msg) {
                alert("fail " + msg.d);
            }
         });
        });
    });
+2  A: 

Looks like you need to have your click event return false.

$("#Button1").click(function()
{
    $.ajax(...);

    return false;
});
Aaron
Thanks Aaron, I assume this is to stop the postback to the servr..
Jreeter
That is correct sir.
Aaron