What does `success: function (msg)` mean in my jQuery Ajax call?

I have two jQuery Ajax calls that I combine on a page. I am stuck on success: function()in each, as one success: function(msg)and the other success: function(data). I'm not sure what they both mean, and that they should be in combined code. I put the two calls below separately and combined them until I still have them.

Ajax Request # 1: there are php functions on this page $msg .= "<div class='pagination'><ul>";. Not sure what this is about.

$.ajax
({
    type: "GET",
    url: "new_arrivals_data.php",
    data: "page="+page,
    success: function(msg)
    {
        $("#gallery_container").ajaxComplete(function(event, request, settings)
        {
            gallery_show();
            loading_hide();
            $("#gallery_container").html(msg);
        });
    }
});

Ajax Request # 2: As far as I see, there is no call in this php file data. I don’t know what it refers to function(data).

$.get("new_arrivals_data.php",{imgs: value}, function(data){
    $("#gallery_container").html(data);
});

Combined query: I put ?where I msgwas in the original call, since I'm not sure what to put in it.

$.ajax
({
    type: "GET",
    url: "new_arrivals_data.php",
    data: {page:page, imgs: value},
    success: function(?)
    {
        $("#gallery_container").ajaxComplete(function(event, request, settings)
        {
            gallery_show();
            loading_hide();
            $("#gallery_container").html(?);
        });
    }
});
+5
3

msg data - . , .

JavaScript.

ajaxComplete success::

success: function( whatever_you_want_to_call_it ) {
        gallery_show();
        loading_hide();
        $("#gallery_container").html( whatever_you_want_to_call_it );
}

$.get("new_arrivals_data.php",{imgs: value}, function( i_like_ice_cream ){
    $("#gallery_container").html( i_like_ice_cream );
});

, . .

, , . .

.

$.get("new_arrivals_data.php",{imgs: value}, function(){

    var i_like_ice_cream = arguments[0];
    $("#gallery_container").html( i_like_ice_cream );

});

. , .

+3

. data, msg , .

, success , . , jQuery success, , ajax. ( ajax). , , - , .

, :

function workOnBob(aWorker) {
   aWorker("Bob")
}

var sayHi = function(name) { alert("Hello " + name); };
var getMarried = function(groom) { alert(groom + " is getting married!"); };

workOnBob(sayHi); // "Hello Bob"
workOnBob(getMarried); // "Bob is getting married!"

, workOnBob , . "Bob". sayHi getMarried, , -, (name groom ). "", - .

, , .

+2

, , ajax. , , , . html, resp, logged.

+1

All Articles