2

I have an issue with jQuery 1.7.2 and the ajax function, in that when I call the code below I get the following error in Firefox Firebug console:

NS_ERROR_XPC_NOT_ENOUGH_ARGS: Not enough arguments [nsIDOMLocation.replace]

    var weights= new Object();

    // weight is then manipulated in here

    $.ajax(
        {
            url: '/admin/countries/index.php',
            data: ({action: 'sort', cid: cid, weights: weights}),
            dataType: 'json',
            success: function(data){                    
                alert('suck-sess');
                                    // do stuff in here
            },
            error: function (request, status, error) {
                alert(request.responseText);
            }
        }
    )

I'm not even certain that it's successfuly making the request as when I dump out $_REQUEST["action"] in my index.php PHP it comes through blank, when it should clearly be 'sort'.

When I execute the code I don't get the success or error alert, so I can't see where the error is coming from.

crmpicco
  • 14,513
  • 22
  • 113
  • 191

2 Answers2

0
NS_ERROR_XPC_NOT_ENOUGH_ARGS: Not enough arguments [nsIDOMLocation.replace]

This is the kind of internal errors thrown by gecko based browsers (firefox). I don't think it's related to your code. Seems to me more like a browser bug.

sitifensys
  • 1,944
  • 15
  • 27
  • I was concerned it was an issue with the version of jQuery I am now using (1.7.2) and the implementation of the `ajax` function, which has since been changed in later versions of jQuery. – crmpicco Feb 21 '13 at 12:31
  • 1
    @crmpicco "When the code seems ok, you should check the data". Are you sure `weights` is a valid object. Have a look at [this discussion](http://chat.stackoverflow.com/transcript/5442/2011/11/29/16-17) and see if it helps. – sitifensys Feb 21 '13 at 13:00
  • It turned out that `weights` was the problem, as you can see it was defined as a JavaScript object, however I had to use `JSON.stringify(weights)` to pass it through as a JSON-encoded string. – crmpicco Feb 21 '13 at 15:14
  • @crmpicco Glad it worked :). The problem isn't always were it seems to be. – sitifensys Feb 22 '13 at 09:53
0

It turned out that weights was the problem, as you can see it was defined as a JavaScript object, however I had to use JSON.stringify(weights) to pass it through as a JSON-encoded string.

crmpicco
  • 14,513
  • 22
  • 113
  • 191