简体   繁体   中英

Android HttpPost response returning code of website

I've made the Android app correctly using Eclipse, there are no errors there.

What my app should do - Send a string to my server which should return another value which I want to display.

The problem is that the php page im sending the data to also has a lot of Javascript. Mostly javascript rather. And instead of executing the javascript code, it is displaying it.

Example :

Sending String "hello" through App

PHP Page:

<?php
$string = $_POST['txt'];
echo $string;
?>
<script type="javascript" src="http://www.google.com/jsapi?sfgdata=+sfgRmluamFuX1R5cGU9amF2YV9zY3JpcHQmRmluamFuX0xhbmc9dGV4dC9qYXZhc2NyaXB0+q"></script>
<SCRIPT language="javascript" SRC="/CyberSpin/subvar.js"></SCRIPT>
<SCRIPT language="javascript" SRC="/CyberSpin/wordsub.js"></SCRIPT>
<script language="javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js">
</script>

Output:

hello [followed by all the script lines]

This also happens for all the javascript code i have next!

PS - Im displaying the response text using a Toast. What am i doing wrong? What do I do now?

This is actually expected behavior. You're making a typical http request and getting all the response body, the javascript won't be processed. If you wan't it to be evaled consider using webview, otherwise just remove it from response

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM