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

  • Home
  • SEARCH
  • 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 9211033
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T01:12:21+00:00 2026-06-18T01:12:21+00:00

I updated jquery so i could play with the new jquery mobile ui 1.3

  • 0

I updated jquery so i could play with the new jquery mobile ui 1.3 and for some reason my form no longer update page any more, it worked previously but it wasn’t through ajax, it simply submitted the form without ajax, I would however like ajax to just fetch the new data and append it to the div instead of reloading the whole page again when the popup closes.

I use a popup module for the form and on submission it should append the new information to #content ul

The JS.

<!-- Load Json data and events -->
<script type="text/javascript">
    jQuery('#new_rave').live('submit',function( event ) {
        $.ajax({
            url: 'http://whoops/goodtimes',
            type: 'POST',
            dataType: 'json',
            data: $('#new_rave').serialize(),
            success: function( data ) {
                for( var id in data ) {
                   jQuery('#').html(data[id]);
                }
            }
        });
        return false;
    });
    $(document).ready(function() {
        $.getJSON('http://whoops/goodtimes', function( goodtimes ) {
            $.each(goodtimes, function( goodtime ) {
        var output = 
            "<li><a href="+this.goodtime.id+">" + 
            "<h3>" + this.goodtime.title + "</h3>" +
            "<p>" + this.goodtime.post + "</p>" +
            "<p class='ui-li-aside'><strong>" + 
                this.goodtime.created_at + "</strong></p>" +
            "</a></li>";
            $('#content ul').append(output).listview('refresh');
        });
        });
    });
</script>

The form

<!-- New item Popup -->
<div data-role="popup" class="ui-content"
data-overlay-theme="a" data-position-to="window" id="add">
    <form id="new_rave">
        <label for="goodtime_title">Title</label>
        <input type="text" name="goodtime[title]" id="goodtime_title">
        <label for="goodtime_post">Rave</label>
        <div data-role="fieldcontain">  
        <textarea name="goodtime[post]" id="goodtime_post"></textarea>
        </div>
        <input type="submit" value="submit">
    </form>
</div>

and the content div

<div id="content" data-role="content">  
    <ul data-role="listview" data-theme="d" data-divider-theme="d"></ul>
</div><!-- /content -->
  • 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-06-18T01:12:22+00:00Added an answer on June 18, 2026 at 1:12 am

    Intro

    Your problem is probably due to $(document).ready(function(){. In jQuery Mobile, Ajax is used to load the content of each page into the DOM as you navigate. Because of this $(document).ready() will trigger before your first page is loaded and every code intended for page manipulation will be executed after a page refresh.

    Everything here can be found described with more details in my personal blog article.

    In case this is not a problem, use Firefox/Chrome plugin Firebug to test if ajax call has reached a server and if response has been received.

    Last thing, don’t refresh listview every time you append a new element. listview refresh is a huge time sink, every refresh can last around 50ms but do it numerous time and your restyling could go forever.

    Solution

    So change this:

        $.getJSON('http://whoops/goodtimes', function(goodtimes) {
          $.each(goodtimes, function(goodtime) { 
            var output = 
            "<li><a href="+this.goodtime.id+">" + 
                    "<h3>" + this.goodtime.title + "</h3>" +
                    "<p>" + this.goodtime.post + "</p>" +
                    "<p class='ui-li-aside'><strong>" + this.goodtime.created_at + "</strong></p>" +
                "</a></li>";
            $('#content ul').append(output).listview('refresh');
         });
        });
    

    to this:

        $.getJSON('http://whoops/goodtimes', function(goodtimes) {
          $.each(goodtimes, function(goodtime) { 
            var output = 
            "<li><a href="+this.goodtime.id+">" + 
                    "<h3>" + this.goodtime.title + "</h3>" +
                    "<p>" + this.goodtime.post + "</p>" +
                    "<p class='ui-li-aside'><strong>" + this.goodtime.created_at + "</strong></p>" +
                "</a></li>";
            $('#content ul').append(output);
         });
         $('#content ul').listview('refresh');
        });
    

    EDIT

    Your problem with constant post repeating comes to how jQuery Mobile handles event binding. Because pages are constantly revisited each time events are going to be bound over and over. In your case that would be an event that executes JSON call.

    This can be prevented in several ways, most common one is to unbind event before binding it. For example:

    $('#test-button').off('click').on('click', function(e) {
        alert('Button click');
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm having some issues with my code maybe you could help? Jquery: [updated] <script>
I'm new to js/jQuery. Forgive this horrible script. I'm lost. *(Updated with global variable
I'm curious as to how to get my AJAX/JQuery to update the page with
I'm trying to update a database using html form + jquery + php When
I have a page which uses jquery's ajax functions to send some messages. There
I have a page which uses jquery's ajax functions to send some messages. There
I have updated my jSon object using the code <script type=text/javascript > jQuery(document).ready(function($){ var
I'm trying to use struts2-jquery grid plugin. When debugging my gridmodel is getting updated
Hey, I've tried to update jQuery to its latest version on a system I'm
I would like to use jquery to update my attribute value, because I want

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.