Android Question Webview can't get Post Data Javascript - Failed to Load ... Response for preflight is invalid

scsjc

Well-Known Member
Licensed User
Longtime User
I launch a WebView and the POST is runing ok
but can't get a data post, i see on log "Response for preflight is invalid" and diferent URL (parent URL)

Some one know to fix this problem ???
thanks



B4X:
'
#Region Module Attributes
   #FullScreen: False
   #IncludeTitle: True
   #ApplicationLabel: SaveHTML
   #VersionCode: 1
   #VersionName:
   #SupportedOrientations: unspecified
   #CanInstallToExternalStorage: False
#End Region

'Activity module
Sub Process_Globals
   'These global variables will be declared once when the application starts.
   'These variables can be accessed from all modules.
End Sub

Sub Globals
   'These global variables will be redeclared each time the activity is created.
   'These variables can only be accessed from this module.
 
   Private wvJS As WebView
   Private wwX As WebViewExtras
End Sub

Sub Activity_Create(FirstTime As Boolean)
   wvJS.Initialize("wvJS")
   Activity.AddView(wvJS,0,0,100%x,100%y)
 
   wvJS.JavaScriptEnabled=True
   wwX.addJavascriptInterface(wvJS, "B4A")
   wwX.addWebChromeClient(wvJS,"chromeclient")

   wvJS.LoadUrl("https://[email protected]&[email protected]")
End Sub

Sub Activity_Resume
End Sub

Sub Activity_Pause (UserClosed As Boolean)
End Sub

Sub wvJS_PageFinished(Url As String)
   'wvJS.LoadUrl("javascript:bridgeactive('Open MsgBox on page Finish')")
End Sub

Sub msg_box(title As String, text As String)
    Msgbox(text,title)
End Sub


with this code HTML:

B4X:
<script>
var jqxhr =    $.post("https://xxxxxxx", {
                   from: xxxx,
                   to: xxxxx
       },
       function(data) {
           B4A.CallSub("msg_box",true, "Title",data);
       })

         .done(function(data) {
             B4A.CallSub("msg_box",true, "Title",data);
         })
         .fail(function(xhr, status, error) {
             B4A.CallSub("msg_box",true, "Title",133323);
         })
         .always(function() {
           
         });


function bridgeactive(pagefinish){
   B4A.CallSub("msg_box",true, "Title", pagefinish);
} 
</script>

B4X:
** Activity (edicion) Resume **
** Activity (edicion) Pause, UserClosed = false **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
Mixed Content: The page at 'https://xxxxxxxxxxxxxxx (Line: 0)
Mixed Content: The page at 'https://xxxxxxxxxxxxxxx (Line: 0)
Failed to load http://xxxxxxxxxxx/index.php: Response for preflight is invalid (redirect) in https://xxxxxxxxxxxx (Line: 0)
** Activity (edicion) Resume **
** Activity (edicion) Pause, UserClosed = false **
 
Last edited:
Top