I've decided to being a slightly ambitious project. Like Drupal
before, I'm trying to create a CMS using JQuery for some of the client
side functionality. At the moment I'm just trying to write the
underlying RPC calls using JSON-RPC (v1.1) (Yes I know its still a
working draft, but I'm trying to get ahead of the game).

I have a weird issue occuring when I make the AJAX call. Using
Firefox, it works as one would expect. But using IE 6, the same call
fails. Chucking in some debugging alerts, and things in, I see that IE
is actually returning a readyState of 4, and a status code of 200...
Yet the error event is still being triggered. When I run a packet
sniffer on the web server, I see the session happen correctly, with
the status code of 200. Any one got any ideas of what I'm missing?

The source looks like this...

jQuery.extend({

        jsonrpcSettings: {
                type: "POST",
                timeout: 5000,
                url: null,
                data: null,
                callback: function() {}
        },

  jsonrpcCall: function( s ) {

    s = jQuery.extend({}, jQuery.jsonrpcSettings, s);
    if (( !s.url || s.url===null ) || ( !s.data || s.data===null )) {
      alert("URL or data is missing!");
      return false;
    }
    if ( s.callback !== null && !jQuery.isFunction(s.callback))
{ return false; }

/*
    try {
 
netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead");
    } catch (e) {}
*/

 
jQuery.ajax({
      url:
s.url,
      type: s.type,
      contentType: "application/json",
      data : s.data,
      dataType: "json",
      beforeSend: function(xhr) {
                                  xhr.setRequestHeader("Accept",
"application/json");
      },
      global: false,
      timeout: s.timeout,
      success: function (data) { alert("It worked!!");  },
      error: function (xhr, status, expobj) { alert("It DIED!!
Horribly"); },
      complete: function(xhr, status) {
        alert("Complete [" + status + "]");
        alert("Status code [" + xhr.status + "]");
        alert("ReadyState is [" + xhr.readyState + "]");
        for(elem in xhr) { alert( elem + " = " + xhr[elem]); }
      }
    });
    return true;
  }
});

And the call for the function is...

      $(document).ready(function(){

        var srvCall = {
                        url: "http://webserver:8888/development/
services.cgi",
                        data: {
                                "version" : "1.1",
                                "method"  : "echo",
                                "params"  : { echo: "hello echo" }
                              },
                        callback: function() { alert("Done?"); }
                      };
        try{
          $("#JSONRPCTest").click( function()
{ $.jsonrpcCall(srvCall); });
        }
        catch(e) {
        }
      });

JSONRPCTest is the ID for a div object.

Reply via email to