在volley StringRequest上禁用Javascript

时间:2015-10-27 19:31:26

标签: javascript android-volley

我的MainActivity中有一个凌空的StringRequest,就像这样

StringRequest strReq = new StringRequest(Method.POST,
            G.serverLevelAdress, new Listener<String>() {

                @Override
                public void onResponse(String response) {
                    // TODO Auto-generated method stub
                Log.e(TAG, "Response to get All Online Users \n "
                            + response);


                }
            }, new Response.ErrorListener() {

                @Override
                public void onErrorResponse(VolleyError error) {
                    // TODO Auto-generated method stub
                    if (error.getMessage() != null)
                        Log.e(TAG, TAG + ": " + error.getMessage());
                    try {
                        G.showToast(activity.getResources().getString(
                                R.string.network_error));

                    } catch (Exception e) {
                        // TODO: handle exception
                    }
                }
            }) {
        @Override
        protected Map<String, String> getParams() {
            // Posting params to register url
            Map<String, String> params = new HashMap<String, String>();
            params.put("tag", "getAllOnlineUsers");
            params.put("email", email);

            return params;
        }
    };
    G.getInstance().addToRequestQueue(strReq, tag_string_req);

在本地主机中,一切正常,我可以轻松调用本地服务器。这是我的PHP代码请求并返回其响应:

<?php

if (isset($_POST['tag']) && $_POST['tag'] != '') {
// get tag
$tag = $_POST['tag'];

// include db handler
require_once 'DB_Functions.php';
$db = new DB_Functions();

// response Array
$response = array("tag" => $tag, "error" => FALSE);

// check for tag type
if ($tag == 'login') {
    // Request type is check Login
    $email = $_POST['email'];
    $password = $_POST['password'];

    // check for user
    $user = $db->getUserByEmailAndPassword($email, $password);
    if ($user != false) {
        // user found
        $response["error"] = FALSE;
        $response["uid"] = $user["user_unique_id"];
        $response["user"]["name"] = $user["name"];
        $response["user"]["email"] = $user["email"];
        $response["user"]["created_at"] = $user["created_at"];
        $response["user"]["updated_at"] = $user["updated_at"];
        $response["user"]["paycard"] = $user["paycard"];
        $response["user"]["phone"] = $user["phone"];
        $response["user"]["real_name"] = $user["real_name"];
        $response["user"]["role"] = $user["role"];
        echo json_encode($response);
    } else {
        // user not found
        // echo json with error = 1
        $response["error"] = TRUE;
        $response["error_msg"] = "Incorrect email or password!";
        echo json_encode($response);
    }

 } else {
$response["error"] = TRUE;
$response["error_msg"] = "Required parameter 'tag' is missinggg!";
echo json_encode($response);
 }
 ?>

问题是当我在在线主机上加载的代码我收到此消息时作为响应:

<noscript>This site requires Javascript to work, please enable Javascript in your browser or use a browser with Javascript support</noscript>

问题出在哪里?如何通过我发送请求的活动禁用Javascript?

非常感谢你的关注。

0 个答案:

没有答案