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 8067919
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T12:29:24+00:00 2026-06-05T12:29:24+00:00

I am building a PhoneGap app using jQuery Mobile. My JSONP cross domain communication

  • 0

I am building a PhoneGap app using jQuery Mobile. My JSONP cross domain communication works, but have an issue when jQuery Mobile is included. Without it everything works as expected, included, it stops working.

I’ve reduced code to simplest form – Serialize data, encode and call CrossDomain PHP file using JSONP. Execute success function. I thought it might be bad JS but “alert” works and no JS errors. But the $(‘#section1’).html(“SECTION 1 – ” + data.message); doesn’t update. Note: When I remove jQM it all works!

Below is the HTML and the PHP code it calls. It’s as though the jQueryMobile AJAX call is interfering with the update of the .html code. Any ideas? I’m stumped.

Ajax4d.htm

<html><head><title>First jQueryMobile Example</title>
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.1.0/jquery.mobile-1.1.0.min.css" />
<script src="http://code.jquery.com/jquery-1.7.1.min.js"></script>
<script src="http://code.jquery.com/mobile/1.1.0/jquery.mobile-1.1.0.min.js"></script>

  <script>
     $(document).ready(function() {
         $("#foo").submit(function(event) {                
             event.preventDefault();
             var $form = $(this), 
                         $inputs = $form.find("input, select, button, textarea"),
                         serializedData = $form.serialize();
             var postData = serializedData;
             var urlStr = "http://www.fohost.co/testURLd.php?";

             alert (urlStr + encodeURI(postData));                    
             $.ajax({
                  url: urlStr,
                  data: encodeURI(postData),
                  dataType: "jsonp",
                  success: function(data){
                     alert("SUCCESS callback before HTML update: " + data.message);
                     $('#section1').html("SECTION 1 - " + data.message);
                     }
                  });
             });
         }); 
</script>
</head>

<body>
    <section id="register_page" data-role="page" data-theme="b">
        <div data-role="content">
            <form id="foo" method="get" action="">
                <fieldset data-role="fieldcontain">
                    <label for="username">Username:</label>
                    <input type="text" name="username" id="username" value="Chris" placeholder="Username"/>
                </fieldset>
                <fieldset class="ui-grid-a"><input type="submit" value="Send" /></fieldset>
            </form>
        </div>
        <div id="section1">SECTION</div>
    </section>
</body>
</html>

testURLd.php

<?php
header("content-type: application/json"); 

$user = $_GET['username'];

$rtnjsonobj->success = "true";
$rtnjsonobj->user = $user;
$rtnjsonobj->message = "Stored User: " . $user;

echo $_GET['callback']. '('. json_encode($rtnjsonobj) . ')';    
?>
  • 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-05T12:29:25+00:00Added an answer on June 5, 2026 at 12:29 pm

    When you use the submit() method, but fire an ajax call, you aren’t prohibiting the form from submitting.

    Add a return false; to the end of the $("#foo").submit method. This will prohibit the page from reloading onclick.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am building an iPhone app using jQuery Mobile, jQuery 1.7.2, and PhoneGap trying
I am building a mobile app using jquery mobile and phonegap for both android
I'm building a simple content app using PhoneGap + jquery mobile. My AdMob banner
I am building a cross-platform mobile app in jQueryMobile and PhoneGap and am currently
I am currently building a game in phonegap using jQuery Mobile frame work. What
I'm building a mobile app using HTML, CSS, Javascript and jQuery. Is there a
I am building an app using Phonegap and JQuery. The app stores ( using
I am building an phonegap app using html5 and css. I have a iBall
Info: I am using JQuery Mobile (in Phonegap) for building pages and navigating via
I am building an Android app using phoneGap and I have successfully added the

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.