Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

167
Vistas
Send XHR request from html file wrapped into webview using javascript

I have index.html file it contains CSS,HTML and JavaScript code JavaScript code is sending request using XMLHttpRequest to .php file on the server, .php file echoing some data.

I wrap HTML code into android app WebView as string (not using loadUrl function) using code that i found on this source

Java:

// Create an unencoded HTML string
// then convert the unencoded HTML string into bytes, encode
// it with Base64, and load the data.
String unencodedHtml =
     "<html><body>'%23' is the percent code for ‘#‘ </body></html>";
String encodedHtml = Base64.encodeToString(unencodedHtml.getBytes(),
        Base64.NO_PADDING);
myWebView.loadData(encodedHtml, "text/html", "base64");

Also enabled Internet and JavaScript support

<manifest ... >
    <uses-permission android:name="android.permission.INTERNET" />
    ...
</manifest>

webSettings.setJavaScriptEnabled(true);

But i can't send GET/POST request from JavaScript inside app to remote .php file on server.

Everything is working if i upload index.html file to server and send request to .php file I can send request without CORS issue from localhost too.

Is there any way to avoid wrapp entire Website into WebView and use loadUrl instead of loadData function or am i missing something?

Can i send XHR/Fetch requests from app to server and receive data into WebView?

I am still searching for answer but still not found working solution

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda