简体   繁体   English

网站的Android HttpPost响应返回代码

[英]Android HttpPost response returning code of website

I've made the Android app correctly using Eclipse, there are no errors there. 我已经使用Eclipse正确制作了Android应用,那里没有错误。

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. 问题是将数据发送到的php页面也有很多Javascript。 Mostly javascript rather. 大多是javascript, And instead of executing the javascript code, it is displaying it. 而不是执行javascript代码,而是显示它。

Example : 范例:

Sending String "hello" through App 通过应用程序发送字符串“ hello”

PHP Page: PHP页面:

<?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! 接下来的所有JavaScript代码也会发生这种情况!

PS - Im displaying the response text using a Toast. PS-我使用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. 您正在发出典型的http请求并获取所有响应正文,因此将不处理javascript。 If you wan't it to be evaled consider using webview, otherwise just remove it from response 如果您不想逃避,请考虑使用webview,否则将其从响应中删除

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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