开发者

Submitting form without refresh

I am retrieving Google's weather API XML and using PHP. I'm retrieving the weather for any searched city.

Now, this "app" is under a tab and whenever I submit the form it refreshes and I want to prevent this.

Is it possible? This will be implemented in a dashboard - thats the reason I want to prevent the refresh.

This is what I mean: http://www.screenr.com/30As

The entire code is here: http://jsfiddle.net/ZshpF开发者_如何学JAVA/ Simply, copy paste the code in a php file and it will work.


You'll want to use AJAX. Since you mention jQuery in the tags, it has a very handy function for making the call to the server. But making the call from the JavaScript is only half the story, you'll also need something on the server listening for that call. It would essentially be another PHP script which acts as a page in and of itself, but would return data in the form of (most likely) JSON instead of HTML. It's not meant to be human-readable, but rather to be a sort of web service for your JavaScript code to use.

You can find a simple example here.


I think you can use jQuery ajaxForm

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜