Question

I am using following code to upload photo to facebook with ajax:

function _upCover(id, imgURL) {
    $('#uploadb').hide(0);
     imgURL ="myimageurl.jpg"  

     var postMSG= "my test";
 var url='https://graph.facebook.com/me/photos?access_token='+accessToken+"&message="+postMSG;

 var formData = new FormData();
 formData.append('url',imgURL);

  $.ajax({          type: 'POST',
                    url: url,
                    data: formData,
                    cache: false,
                    contentType:  false,
                    processData: false,

                    success: function(data){  
                                                 uploads(id);   },

                    error: function(data){
                                              failed(id);       }
                });


}

This works fine in Firefox but not in other browsers because it uses FormData() function. Is there any way to do it without using FormData() so it works in all browsers?

Was it helpful?

Solution

Try this solution: How to get form data as a object in jquery Besides, FormData() should be supported not only in Mozilla, but also in Chrome and Safari 5+.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top