JQuery simple ajax request not working

All I want to do is get the page and return its contents:

        $.ajax({
            type: "POST",
            url: "alg.aspx",
            data: sqQstring,
            success: function(msg) {
                alert("Data Saved: " + msg);
            }
        });

This does not give a warning, and there are no errors in the console. I printed the sqqString value and is equal to:

cc=12&cr=11&sq=10,4|10,4

I also changed the url in ajax:

http://localhost:2728/shaper/alg.aspx

This makes a warning field, but without data.

I visited the page:

http://localhost:2728/shaper/alg.aspx?cc=12&cr=11&sq=10,4|10,4

And he shows a lot of data.

Can anybody help?

+3
source share
2 answers

Add an error handler to make sure you do not receive an error message ...

   $.ajax({
        type: "POST",
        url: "alg.aspx",
        data: sqQstring,
        success: function(msg) {
            alert("Data Saved: " + msg);
        },
        error: function (request, ajaxOptions, exception){
                alert(request.status);
                alert(exception);
            }    
    });

In addition to this, use Firefox with Firebug and look at the "Net" tab to see the actual request and response.

, , , GET, POST AJAX.

,

$.get("http://localhost:2728/shaper/alg.aspx?cc=12&cr=11&sq=10,4|10,4", 
    function (data) {
        alert("Data Saved: " + data);
    }
);

, , , !

+6

, , , ( ) GET, ajax POSTing.

+1

Source: https://habr.com/ru/post/1751576/


All Articles