title: passing function name as string in jquery ajax
body: <p>I don't know if the title of this question is right or not, so please if someone has a better description edit it.</p>
  
  <p>I've anchor element with custom attribute as follows (Update: according to @Rune solution and @Shauna comment)</p>
  
  <pre><code>&lt;a href="#" class="call-method" data-url="/Pages/mustafa/test_dialoge.aspx/GetDate" data-data="" data-success="handleResult"&gt;call me&lt;/a&gt;
  </code></pre>
  
  <p>Where data-url, data-data, data-success, and data-error are custom attributes</p>
  
  <p>Then i use the following snippet to attach some scripts to it</p>
  
  <pre><code>$('.call-method').live('click', function () {
  
      var obj = $(this);
      var options = new Object();
  
      options.url = obj.attr('data-url').toString();
      options.success = obj.attr('data-success');
      options.error = obj.attr('data-error');
      options.complete = obj.attr('data-complete');
  
      var _options = JSON.stringify(options);
  
      callServerGetMethod(_options);
  
  });
  
  
    var callServerGetMethod = function (options) {
      var _options = new Object();
      var self = this;
      if (typeof options === 'string') {
        _options = JSON.parse(options, function (key, value) {
          if (typeof self[value] === 'function') {
            return eval(self[value]);
          }
          return value;
        });
      }
  
      $.ajax(
        {
          type: "post",
          dataType: "json",
          contentType: "application/json; charset=utf-8",
          async: true,
          cache: false,
          error:
            function (xhr, ajaxOptions, thrownError) {
              console.log(xhr.statusText);
              console.log(thrownError);
            }
        }, $.extend(_options));
    };
  </code></pre>
  
  <p>Now I got the following error in browser console</p>
  
  <pre><code>SyntaxError {popStackFrame: function}
  arguments: Array[1]
  get message: function () { [native code] }
  get stack: function () { [native code] }
  set message: function () { [native code] }
  set stack: function () { [native code] }
  type: "unexpected_token"
  __proto__: Error
  arguments: undefined
  constructor: function SyntaxError() { [native code] }
  name: "SyntaxError"
  stack: undefined
  type: undefined
  __proto__: d
  </code></pre>