Get the App
SLTechnology News&Howtos  ›  Development  › 

How to use China Weather Forecast Interface to realize simple Weather Forecast in php

Shulou Source: shulou.com Published: 2022-06-03 08:40:16 10月01日 Update

Editor to share with you how to use the Chinese weather forecast interface to achieve simple weather forecast in php, I believe most people do not know much about it, so share this article for your reference. I hope you will learn a lot after reading this article. Let's learn about it together.

The code is as follows:

The code is as follows:

.all span {font:bold 30px/50px "Song style"; color:red } Weather Forecast here is: city, temperature is temperature, wind direction: wind direction, wind: wind $(function () {$.ajax ({/ / requested address url: "function executed after successful http://127.0.0.1/weather.php",// request success: function (data) {/ / parse the returned data with eval (), convert the string to JSON format var oD = eval ('('+ data+')') / / use jquery-1.8.2 to get elements var $place = $(".place"), $temp = $(".temp"), $wind = $(".wind"), $windPower = $(".windpower"); / / put the returned data to the appropriate location $place.html (oD ["weatherinfo"] ["city"]); $temp.html (oD ["weatherinfo"] ["temp"] + "°"); $wind.html (oD ["weatherinfo"] ["windpower"]) $windPower.html (oD ["weatherinfo"] ["WS"]);}});}) above are all the contents of the article "how to use the Chinese Weather Forecast Interface to achieve simple Weather Forecast in php". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Tags: Weather weather forecast forecast article interface China code content data temperature wind direction success not much location element function address city most Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Linux MariaDB Shulou Technology Docker Redmi