0

I have a form that I am using jquery form to upload files with ajax.

The problem I am having is this.

the url the form is on is http://admin.kaalaphp.com?cmd=cXVKd29jMnlwYW1WajZ1anlKWFIzJTJCR2xyWkt6dEglMkJWbEt1cHNhRFYydGFvbCUyQkJxcTdTZ21hWnlobGJNejY5aw%3D%3D

but the ajax call is to http://kaalaphp.com/ajax_processes/uploadImages.php

when the upload is triggered the following javascript error is generated.

[jquery.form] Server abort: Error: Permission denied to access property 'document' (Error)

This is related to cross domain ajax calls, I am wondering if there is a quick fix to allow this to work.

$(document).ready(function() {
var options = {
crossDomain: true
};
// pass options to ajaxForm
$("#upload_images").ajaxForm(options);
$("#upload_images").on('change', '#media_images', function(){
$("#ajaxUploader").html("");
$("#ajaxUploader").html('<img src="http://kaalaphp.com/images/loading.gif" alt="Uploading...."/> Uploading....');
$("#upload_images").ajaxForm({
target: "#ajaxUploader"
}).submit();
});
}); 

Thanks

3
  • have you done anything about configuring the Access-Control-Allow-Origin header on kaalaphp.com? (going to assume that page isn't supposed to 404?)
    – Scuzzy
    Commented Dec 4, 2013 at 23:17
  • Sorry my bad the link was wrong I have corrected it. Commented Dec 4, 2013 at 23:20
  • I have not done any Access-Control-Allow-Origin info on the domain. Will that allow the ajax uploader to function? How should I set it up? Never worked with it before Commented Dec 4, 2013 at 23:22

1 Answer 1

1

Try configuring an Access-Control-Allow-Origin header on your uploadImages.php file

As a whitelist...

header('Access-Control-Allow-Origin: http://admin.kaalaphp.com, http://kaalaphp.com');

or alternatively...

header('Access-Control-Allow-Origin: *');

Place this code before any headers are sent

3
  • still get the error [jquery.form] Server abort: Error: Permission denied to access property 'document' (Error) the error is being generated by jquery.form.js Commented Dec 4, 2013 at 23:28
  • And that's with the wildcard * header as well? If not, I think we're going to need to see more code of your form/jquery setup.
    – Scuzzy
    Commented Dec 4, 2013 at 23:33
  • Yah I tried both neither worked. I have posted the javascript function. Commented Dec 4, 2013 at 23:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.