且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在yii2 php中添加微调器/加载器

更新时间:2022-11-27 17:05:27

未对用户请求进行验证

$m = MetersInventoryStore::findOne($_REQUEST['selected_meters']);

太多了

$msn = $m->meter_serial;

这样做

$api_url = 'http://xx.xxx.xxx.xxx:7000/api/meters/GetByMsn/' . $m->meter_serial . '/' .$date_time;

需要将卷曲请求移至分离的方法

Curl request need to be moved to separated method

function curlRequest(msn) {
  $api_url = 'http://xx.xxx.xxx.xxx:7000/api/meters/GetByMsn/' . $msn . '/' .$date_time; // my base URL
  $curl = curl_init($api_url);
  curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
  curl_setopt($curl, CURLOPT_TIMEOUT, 1000);
  curl_setopt($curl, CURLOPT_HTTPHEADER, array('Authorization:key'));
  $curl_response = curl_exec($curl);
  $json = json_decode($curl_response); // WTF snake case only in Python

  return $json->data->Response;
}

现在回答你的问题
你需要添加点击事件到你的按钮。你使用Yii2他的jQuery用于更强大的DOM工具。使用$ .hide()和$ .show()为你的按钮类和绘制预加载器。如果您需要来自服务器的保存数据的反馈,您可以使用Promise。

And now answer to your question You need add click event to your button. You using Yii2 his have jQuery for more powerful DOM-tools. Use $.hide() and $.show() for you button class and draw preloader. You can use Promise if you need feedback from server of his save data.