Submit to external url via Ajax & get return I need a Drupal form to submit a file to an external server using ajax. I have done the form using Form API and I am able to submit it via Ajax, But the Drupal throbber never stops and I am not able to get the returned value. But in firebug I can see it to be returned.

My Code:

function upload_video_episode($form, &amp;$form_state){

     $form['files'] = array(
        '#type' =&gt; 'file',
        '#title' =&gt; t('Video'),
        '#description' =&gt; t('Upload a file, allowed extensions: mov, mp4, avi, mkv'),
      );

     $form['submit'] = array(
           '#type' =&gt; 'submit',
           '#value' =&gt; t('Submit'),
           '#ajax' =&gt; array( 
           'path' =&gt; url('http://web.com/test.php', array('external' =&gt; true)),
           'callback' =&gt; 'upload_video_test',
           ),
      );

    $form['#action'] = url('http://198.199.95.235:8080/dev/test.php', array('external' =&gt; true));
    return $form;
}

function upload_video_test(){
    return "Done!";
}


The throbber just keep rotating non-stop.



However, in firebug I can see the form have been submitted and values returned.



Console seems to be showing some error, possibly related to Non-Origin. But in my case the data is already submitted.

Error: Permission denied to access property 'document'





Is what I have done so far correct? 
I want to get the returned value and store it in a hidden form field or something. 
Or is Drupal Form API not capable of handling external urls?


Any help would be highly appreciated.
Sounds like it's spinning forever because of the js error. 

Where is the error occurring? In jQuery library? 

If so use an uncompressed version of jQuery and it may be easier to debug. 

Maybe even temporarily hack jQuery core to remove error and see if that fixed your problem before spending time figuring out how to fix it properly...