尝试使用jquery/php/xml检索Yahoo天气 [英] Trying to retrieve yahoo weather using jquery / php / xml

查看:85
本文介绍了尝试使用jquery/php/xml检索Yahoo天气的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

此功能有什么问题?

function yahooWeather(){
    var loadPage = 'yahooweather.php?p='+ $("#myCity").val();
    $("#yahoo").html('<img src="loading.gif" align="absmiddle">');
    $("#yahoo").load(loadPage);
}

还有另一种编写此函数的方法.我不确定它是否能够读取所需的.val,因为我知道它已设置,因为我在上一个函数中使用它来测试它是否已设置,所以我想也许是我的加载调用.

Is there another way to write this function. Im unsure if its able to read the .val required, tho i know it is set as i used it in a previous function to test that it was being set, so im thinking its maybe my load call.

http://www.wetterkanal.tv/

这是页面.通过单击按钮调用此功能后,应获取选择城市"选项设置的值,然后将天气加载到下面的div中.我已经将此CSS设置为绿色,因此我知道它已加载.我也知道我的php脚本就像通过以下操作来对其进行测试一样:

This is the page. This function once called by clicking the button, should get the value set by the "select city" option then load the weather in a div below. I have set the css to this div as green so i know it loads. I also know that my php script works as if i test it by going to the following:

http://wetterkanal.tv/yahooweather.php?p=ASXX0001

它可以正确地吸引天气.请帮忙!

it pulls the weather in correctly. Please help!

推荐答案

您的问题是,单击按钮时,button元素将重新加载页面.

Your problem is that the button element will reload the page when the button is clicked.

您需要将onclick属性更改为onclick="yahooWeather(); return false;".

You need to change your onclick attribute to onclick="yahooWeather(); return false;".

这篇关于尝试使用jquery/php/xml检索Yahoo天气的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆