title: jQuery Ajax success variable
body: <p>I have the next function. My PHP script returns an array with element <code>error</code> with value 'ERR':</p>
  
  <pre><code>var updatePaymentType = function(plan_pt_id, pt_id){
      var error = null;
      var data = new Object()
      data["function"]             = "update";
      data["payment_type_id"]      = pt_id;
      data["plan_payment_type_id"] = plan_pt_id;
      data["data"]            = $("#saveform").serializeArray();
      $.ajax({
          type: "POST",
          url: "&lt;?=ROOT_PATH?&gt;/commission/plan/edit/id/&lt;?=$this-&gt;editId?&gt;",
          data: data,
          dataType: "json",
          success : function (data)
          {
              error = data['error'];
              alert(error); // All works. Output ERR
          }
      });
      alert(error); // Not work. Output null
      return error;
  };
  </code></pre>
  
  <p>My function should returns an error. But it returns <code>null</code>.
  Thank you very much.</p>