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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T11:41:51+00:00 2026-06-18T11:41:51+00:00

I have a jQuery mobile form set up that runs an ajax request. The

  • 0

I have a jQuery mobile form set up that runs an ajax request. The problem is not request however it’s the fact that jQuery mobile loads out the page content when the submission is sent. This in turn means that the error that I have added to the current page then get’s removed when the page get’s swapped around (if you’ve used jquery mobile you’ll know how the page hashing etc works).

p.s Wrapping the form in non-ajax class will not work as it will stop my ajax running.

This is how I have it set up…

        <!--Log in/Go to register page -->
    <div data-role="page" id="one">
        <div data-role="header">
            <h1>Register of Log In</h1>
        </div>
        <div data-role="content">
            <h2>Log In form</h2>

            <form id='logInForm' action="#" method="POST">
                <div data-role="fieldcontain">
                    <label for="email">Email address:</label>
                    <input type="text" name="emailLogIn" id="emailLogIn" value=""   />
                    <br>
                    <label for="password">Password:</label>
                    <input type="password" name="passwordLogIn" id="passwordLogIn" value=""   />
                    <br>
                    <button type="button" aria-disabled="false">Submit</button>
                </div>
            </form>

            <p><a href='#two'>Not a member? Register here</a></p>

        </div>
    </div>
    <!-- /page one -->

JQuery

$(function() {
var logInFormData = $('#logInForm');

$('#logInFor').submit(function(){
    $.ajax({
        url: 'http://www.mysite.co.uk/project/logIn/logIn.php',
        type: 'post',
        data: logInFormData.serialize(),
        dataType: 'json',
        crossDomain : true,
        timeout: 5000,

        success: function(logInReturn){
            if(logInReturn.message[1]){
                localStorage.clear();
                $('form#logInForm').append("<div class='inputError'><p>" + logInReturn.message[1] + "</p></div>");
            }
            else if(logInReturn.message[2]){
                localStorage.setItem('userHandle', logInReturn.message[2].userHandle);
                localStorage.setItem('userId', logInReturn.message[2].userId);              
                window.location ='selectProject.html';
            }
        },

        error: function(){
            alert('There was an error loading the data. Contact the admin.');
        }
    });
   });
});

so as you can see on result of an error from my PHP i’m adding a div on to the page but this page is then swapped out and replaced with an identical page minus the div. Very annoying. I’m guessing there is a way to append it after the page swap?

Thanks.

  • 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-18T11:41:52+00:00Added an answer on June 18, 2026 at 11:41 am

    When you submit the form, you want to suppress it’s action. Like so:

    $('#logInForm').submit(function(e){
        e.preventDefault();
        $.ajax({ 
    

    Or you can return false:

    $('#logInForm').submit(function(){
        $.ajax({
            // Your Ajax code
        });
        return false;
    });
    

    Otherwise, do not use the submit event, but select a click event on your button. Here is an example using click(): http://jsfiddle.net/Twisty/zaJud/

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

Sidebar

Related Questions

I have a Jquery Mobile page into which I'm loading a form via AJAX.
I have a form that spans multiple pages in jQuery Mobile. I'm using multi-page
I have a jquery mobile form that is wrapped around two pages : <form
Hi guys my problem is that I have a jquery mobile site with links
I have a form on my jQuery Mobile site that I would like to
I have a form in a Code Igniter view in my jQuery Mobile application.
I have a popup select box in a form in my jQuery Mobile application.
I have a Jquery Mobile collapsible set , which can have any number of
I have a code in jquery mobile that will add buttons dynamically in a
I have a page in JQuery mobile, which contains a form. The form has

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.