0

Possible Duplicate:
$.post throwing “Illegal invocation ”

I am getting this error,

Uncaught TypeError: Illegal invocation.

And when i expand it i get these errors.

  • upload test.js:53
  • (anonymous function) test.js:42

Here is my code.

$("#continue").click(function() {
    upload();
    alert("clicked");
    return false;
});


function upload(){
      $.post('http://127.0.0.1/web/upload/', {
            image_src:image_src,
            page_domain:page_domain,
            product_name:productName
      }, function(data){
        $("#MAIN").html(data);
      })
    return false;
    }

I have looked at other versions of this error over stackoverflow but none seem to have a working answer for my code. Thanks for reading.

Community
  • 1
  • 1
user1527354
  • 195
  • 2
  • 11

1 Answers1

0

It is not that simple to upload image (files in general) data using "ajax" call. Check this answer for more information How can I upload files asynchronously? and php image upload with jquery post

Community
  • 1
  • 1
Peter Pajchl
  • 2,699
  • 21
  • 24
  • I'm not uploading it using ajax, Im just simply sending the path of the image to my current upload script. – user1527354 Jul 17 '12 at 10:48
  • @user1527354 Where are you getting "image_src" and is it of type "String"? – Peter Pajchl Jul 17 '12 at 11:44
  • its from image_src = image.attr("src"); so basically its just the src value of a tag. – user1527354 Jul 17 '12 at 16:04
  • Since I can't see how are your variables initialised, I suggest you modify your post to use first hardcoded "string" values, and use only console.log(data) to check response instead of inserting with .html() since I don't know what is your server returning (data type). – Peter Pajchl Jul 18 '12 at 09:22