AJAX NS_ERROR_XPC_BAD_CONVERT_JS: Failed to convert JavaScript argument jquery.js: 7065

I am new to jQuery and Ajax and am having a problem. Im getting an error on my console that:

NS_ERROR_XPC_BAD_CONVERT_JS: Could not convert JavaScript argument @ http://localhost
/jquery.js:7065

Why am I getting this error?

this is Im code Usage:

function upload_file(){
    var file = document.form1.file_upload;
    var date = document.form1.date_added;
    var author = document.form1.author;
    var user = document.form1.user;
    var semester = document.form1.semester;
    var class1 = document.form1.class;
    var subject = document.form1.subject;
    $.ajax({
        type:"get",
        url:"upload_file.php",
        data:{
        "file":file,
        "date":date,
        "author":author,
        "user":user,
        "semester":semester,
        "class":class1,
        "subject":subject
        },
        success:function(result){
        $("#result").html(result);
        }
    });
    }

Im waiting for your answers.

PS: I was looking for a forum, but did not get what I want, so if I missed something, sorry in advance.

+5
source share
4 answers

I think the problem is that you are trying to pass complete JSON objects. You should use values ​​instead of objects. For example, replace:

var subject = document.form1.subject;

with:

var subject = document.form1.subject.value;
+8
source

Use this, I think, parentheses mismatch -

    $.ajax(
                 {
        type:"get",
        url:"upload_file.php",
        data:{
        "file":file,
        "date":date,
        "author":author,
        "user":user,
        "semester":semester,
        "class":class1,
        "subject":subject
        },
        success:function(result)
               {
        $("#result").html(result);
        }
    );
0
source

We had the same error.

Updated to the latest version of jQuery and the problem is resolved.

This one seems to work for some people , saw this solution here too

Hope this helps.

0
source

I came across the same error, but my problem was different.

Turns out I was passing a parameter in an ajax call, which was completely absent in my DOM.

In the case of @ZackValentine (or for those reading this in the future), check the value of all the data items that you are going to pass to the ajax call BEFORE the actual call on its own.

0
source

All Articles