Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AJAX NS_ERROR_XPC_BAD_CONVERT_JS: Could not convert JavaScript argument jquery.js:7065

Tags:

jquery

php

I'm new to jQuery and Ajax and I have run into a problem. Im getting the error on my console that:

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

Why am I receiving this error?

this is the code Im Using:

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 replies.

PS: I Did search the forum but did not get what i want, so if i missed something, sorry in advance.

like image 571
echo_salik Avatar asked Sep 18 '12 08:09

echo_salik


1 Answers

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

var subject = document.form1.subject;

with:

var subject = document.form1.subject.value;
like image 197
Karl Avatar answered Sep 19 '22 00:09

Karl