不同浏览器的不同响应

Gov*_*dav 6 wordpress

我有一个JSON API加载项.

有一个查询用于获取存储在数据库中的结果,但它在不同的系统中提供不同的响应.

我已经清除了浏览器cookie和缓存,但没有任何反应.它一次又一次地存储设备ID,即使它已经存储了

我的功能如下:

public function store_device_id()
{
  global $wpdb;
  $device_id = $_REQUEST['device_id'];
  $device_type = $_REQUEST['device_type'];
  $table_name = $wpdb->prefix . 'ws_details';
  if(!empty($device_id) && !empty($device_type)) :
    $check = $wpdb->get_row( "SELECT * FROM $table_name WHERE device_id like '%".$device_id."%'" );
    if($check == '')
    {
        $result = $wpdb->insert( $table_name,array( 
                'time' => current_time( 'mysql' ), 
                'device_id' => $device_id,
                'device_type' => $device_type ), 
            array( '%s', '%s', '%s'));
        if ($result) 
        {
            $res = 'Device id saved.';
        } else {
            $res = 'Device id did not save.';
        }
    }
    else{
        $res = 'Device already register.';
    }
else :
    $res = 'Please enter device id & device type.';
endif;

nocache_headers();
$post = new JSON_API_Post();
$post = $res;
return array(
      'post' => $post
    );
}
Run Code Online (Sandbox Code Playgroud)

这里有结构:

CREATE TABLE IF NOT EXISTS wp_ws_details( idmediumint(9)NOT NULL AUTO_INCREMENT, device_idvarchar(255)COLLATE utf8mb4_unicode_ci DEFAULT NULL, device_typevarchar(55)COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT'',timedatetime NOT NULL DEFAULT'0002:00:00 ',UNIQUE KEY id(id))ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_unicode_ci AUTO_INCREMENT = 1;

Spa*_*cus 1

如果您从不同的浏览器得到不同的响应,那么肯定存在缓存问题,并且是客户端的问题。在不调用的情况下尝试您的函数nocache_headers(),看看会得到什么样的结果。