首页 > 解决方案 > 在另一个页面中显示搜索结果

问题描述

这是我通过 pin 码搜索数据的 api 代码:

function findPlace(){
    $request = \Slim\Slim::getInstance()->request();
    $pinCode = json_decode($request->getBody());

    try {

        if(1){
            $vendorSearchData = '';
            $db = getDB();

                $sql = "SELECT vendor_name,logo,phone_no FROM vender_list WHERE post_code LIKE :post_code";
                $stmt = $db->prepare($sql);
                $stmt->bindParam("post_code", $pinCode, PDO::PARAM_STR);

            $stmt->execute();
            //echo "<pre>"; print_r($stmt); echo"</pre>";die;
            $vendorSearchData = $stmt->fetchAll(PDO::FETCH_OBJ);

            $db = null;

            if($vendorSearchData)
            echo '{"vendorSearchData": ' . json_encode($vendorSearchData) . '}';
            else
            echo '{"vendorSearchData": ""}';
        } else{
            echo '{"error":{"text":"No access"}}';  
        }

    } catch(PDOException $e) {
        echo '{"error":{"text":'. $e->getMessage() .'}}';
    }
}

这是文件,我在其中调用函数来查找数据。如果它true,那么将导航到另一个页面,但在该页面上我得到空白页:

findPlace(searchVal){
  this.authService.postData(this.vendorSearchPostData, "findPlace")
    .then((result) => {
      this.responseData = result;
      if (this.responseData.vendorSearchData) {
        this.dataSet = this.responseData.vendorSearchData;
        this.navCtrl.push(SearchResultPage, { data: searchVal});
      } else {
        let toast = this.toastCtrl.create({
          message: "No data Found",
          duration: 2000
        });
        toast.present();
      }
    }, (err) => {

    });
  }

如何在另一个页面上显示搜索结果?

标签: phpionic-framework

解决方案


推荐阅读