• Resolved mophilly

    (@mophilly)


    I am having trouble getting an ajax call to behave. Please see Unwanted Page Reload on stackoverflow.com.

    I caught an error being raised in the Firebug console:
    NS_ERROR_XPC_NOT_ENOUGH_ARGS: Not enough arguments [nsIDOMLocation.replace]

    I noted the file is jQuery.js, which claims to be version 1.7.2. jQuery is now at version 1.8.1.

    Would updating the jQuery files in the wp-includes tree resolve this problem?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter mophilly

    (@mophilly)

    When posted yesterday I forgot to mention that this code is part of page template in a child theme. That didn’t seem related, but I add it just in case.

    Thread Starter mophilly

    (@mophilly)

    Further checking reveals that this error is occurring with theme Twenty Eleven, so the theme may not be at issue.

    Thread Starter mophilly

    (@mophilly)

    After testing and decomposing the code involved, the error was found in the data array passed into the ajax call. To aid anyone seeking answers for a similar error here is what I found in the code.

    quizData is an array structured for the WordPress ajax handler.

    Code As Found

    var quizData = {
    	action: 'save_quiz',
    	item: invoice_item,
    	lesson: jQuery("#lesson"),
    	score: ratio };

    There are two problems with this code. First, the jQuery call is assigning a jQuery object to the array value element “lesson”. This results in an “undefined” value in the array that creates the error condition. The missing bit here is the “.val()” function invocation.

    The second one may be the code architecture of the project, but it appears that a jQuery call within array assembly block does not work as expected. In my tests, the data array contained a null value.

    Resolution

    var lesson_id = jQuery("#lesson").val();
    var quizData = {
    	action: 'save_quiz',
    	item: invoice_item,
    	lesson: lesson_id,
    	score: ratio };

    I hope this helps someone.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘jQuery ajax call fails on NS_ERROR_XPC_NOT_ENOUGH_ARGS’ is closed to new replies.