jQuery Ajax-成功功能

I had a perfectly well working jquery ajax function but I'm making it better.

I had this:

  function MakeAjaxCalls () {
      .....
      $.ajax({
        ...
        success: function (msg) {
        var data = msg.hasOwnProperty("d") ? msg.d : msg;
        .... 
        },
        error: function (xhr, status, error) {alert(xhr.statusText);}
      });
  }

It was working fine. Now I want to do this:

   function MakeAjaxCall() {

      $.ajax({
        ...
        success: MySuccessFunction,
        error: MyErrorFunction
      });

    }

    function MySuccessFunction(TheJsonData) {
    alert("baaaam"); // no baaaam
    ....
    }

    function MyErrorFunction(){ 
    ....
    }

The problem is that it never gets to MySuccessFunction. However, when I look at the network activity, I still get the correct data up and down the wire. I tried changing the line with both success: MySuccessFunction(TheJsonData) and success: MySuccessFunction(TheJsonData.d) to add a parameter, but it's still not triggering and in every case, I don't get a javascript error either; it just doesn't trigger.

What am I missing?

If the code is organized in that fashion, MySuccessFunction is not defined at the time you make the call to jQuery.ajax({ ... }).

I would recommend defining the success function -before- your call to jQuery.ajax