0

I am trying to call a javascript function from my webview while giving it two strings. But one of the strings is always null. In my java code it isnt.

myWebView.loadUrl("javascript:Android.SelectTargetDirectory(\"" + fileName + "\", \"" + fileSizes + "\")");

That is what I am doing but with no success

Here the Javascript side:

selectTargetDirectory = function (fileName, fileSizes) {
     $.ajax({
         url: "/UploadFileProductsDialogController/ShowUploadDialog",
         data: { fileName: fileName, fileSizes: fileSizes },
         success: function (result) {
             Controller.ProcessResponse(result);
         },
         error: function (error, response) {
             alert(error);
         }
      );
};

1 Answer 1

1

Give this a try:

myWebView.loadUrl("javascript:SelectTargetDirectory('"
                            + fileName + "', '" + fileSizes + "')");

This is working in my case.

Sign up to request clarification or add additional context in comments.

2 Comments

Please show your code. Are you sure you are passing correct value, and not a null variable? @zanzoken
yes in the debugger fileSizes has a value. I flipped them around and still the same problem. Now fileName does not get passed.

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.