Rendering the response to the javascript

We are working on the application where we need to call the scanner
device
to scan the image. We use DynamicWebTwain. Using the
'HTTPUploadThroughPost'
method we upload the image to the URL. It's all fine.

We need to return the saved image id from the controller action
as Http response. How to send the Http response back to this javascript?

function btnUpload_onclick(court_id)
    {
      var strActionPage;
      var strHostIP;

      var CurrentPathName = unescape(location.pathname);
      var CurrentPath = CurrentPathName.substring(0,
CurrentPathName.lastIndexOf("/") + 1);
    strActionPage = CurrentPath +
"court_images/save_image?court_id="+court_id;
      frmScan.DynamicWebTwain1.HTTPPort = 3000;
      frmScan.DynamicWebTwain1.HTTPUploadThroughPost("localhost", 0,
strActionPage, "imageData.pdf");
      if (frmScan.DynamicWebTwain1.ErrorCode != 0) {
      alert(frmScan.DynamicWebTwain1.HTTPPostResponseString);
    }
    else
      frmScan.submit();
}

Can some one in the group help me out for this issue..

Thanks.
Ratnavel

I may be naive in this area, but it is not entirely clear to me how
this interacts with Rails, which may be why you have not had a reply.

It appears to me that the javascript runs from the browser, pulling
the image data from the TWAIN server and you then post it to the Rails
App. If that is correct, then does can the rails action that receives
the request with the image data not return the id to the browser.

Is it not the frmScan submit that sends a standard post request with
the data to the Rails app?

Sorry this is a question rather than an answer, but it may help get
the ball rolling so that someone else may also be able to help.

Tonypm

Could that be done with RJS?

Set the ID in the controller method (e.g. @id = image.id) and than
pass it to the JS function in the RJS.

page.call("btnUpload_onclick", @id)