Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6583751
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T16:27:00+00:00 2026-05-25T16:27:00+00:00

First let me say I’m new to Ajax. I’ve been reading articles from jquery.com

  • 0

First let me say I’m new to Ajax. I’ve been reading articles from jquery.com and some tutorials but I didn’t figured it out yet how this works on what I’m trying to achieve.

I am trying to get the weather for a searched city using Google’s Weather API XML, without page refresh.

I managed to retrieve the Weather XML and parse the data but everytime I search for a different place, the page reloads since my weather widget is under a tab.

This is what I have in my HTML:

<script type="text/javascript">
$(document).ready(function(){
    // FOR THE TAB
    $('.tab_btn').live('click', function (e) {
        $('.tab_content').fadeIn();
    });


    $(".submit").click(function(){
    $.ajax({
        type : 'post',
        url:"weather.php", 
        datatype: "text",
        aysnc:false,
        success:function(result){
        $(".wedata").html(result);
        }});
    });

});
</script>
<style>.tab_content{display:none;}</style>
</head><body>
<input type="button" value="Show Content" class="tab_btn">
<div class="tab_content">
        <h2>Weather</h2>
    <form id="searchform" onKeyPress="return submitenter(this,event)" method="get"/>
    <input type="search" placeholder="City" name="city">
    <input  type="hidden" placeholder="Language" name="lang">
    <input type="submit" value="search" class="submit" style="width:100px">
    </form>
    <div id="weather" class="wedata">




    </div>
</div>

And here is the actual demo I’m working on: http://downloadlive.org.

Now, if I add action="weather.php" on the search form I get the results, but I get redirected to weather.php which is logical. Without the action="weather.php", everytime I search my index which I’m on, adds up /?city=CITY+NAME which shouldn’t. This should be added to weather.php, get the results and then retrieve them back into my index, if that makes sense?

This is my php code for weather.php: http://pastebin.com/aidXCeQg

which can be viewed here: http://downloadlive.org/weather.php

Can someone please help me out with this please?

Thanks alot

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T16:27:00+00:00Added an answer on May 25, 2026 at 4:27 pm

    You just need to return false; from the click event handler. This will prevent the default action from occuring – in this case, submitting the form. Also, remove the async: false setting. You almost never want synchronous ajax requests.

    $(".submit").click(function(){
        $.ajax({
            type : 'post',
            url:"weather.php", 
            datatype: "text",
            success: function(result){
                $(".wedata").html(result);
            }
        });
    
        return false;
    });
    

    Alternately you can pass a parameter name to the callback and then use event.preventDefault() to accomplish the same result as above:

    $(".submit").click(function(e){
        $.ajax({
            type : 'post',
            url:"weather.php", 
            datatype: "text",
            success: function(result){
                $(".wedata").html(result);
            }
        });
    
        e.preventDefault();
    });
    

    You need to send the form data with the POST. It’s super-easy to do this using .serialize().

    $(".submit").click(function(){
        $.ajax({
            type : 'post',
            url:"weather.php",
            data: $(this.form).serialize(),
            datatype: "text",
            success: function(result){
                $(".wedata").html(result);
            }
        });
    
        return false;
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

First, let me say I'm not a professional programmer, but an engineer who had
Let say I have a post from like this: <form action=myApp/form_action.asp method=post> First name:
First let me say, I am not a coder but I help manage a
First let me say that I've been searching to find a solution for a
Let say I retrieve my list of data... First $Query = mysql_query(SELECT * FROM
First let me say I come from a background in Flash/AS3, which I realize
First off let me just say I'm very new to coding so there are
First let me say I come from a Microsoft background and Visual Studio is
First let me say I have read this useful article thoroughly and am using
First let me say that I did see this article: How to remove AspxAutoDetectCookieSupport

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.