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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T11:52:10+00:00 2026-06-08T11:52:10+00:00

here is the scenario working in CodeIgniter: ( I am sorry if the Question

  • 0

here is the scenario working in CodeIgniter: ( I am sorry if the Question format is not the right one, this is my fist post here.)

  1. I have large form to be submited and it is submiting OK with ajax, after the validation.
  2. In my controller i am passing the username in the view if the user is logged in, and it is placed in a hidden input field in the form. If the user is not logged in the result is

<input type="hidden" id="loggedin" name="username" value="" />

3.in my javascript i check if the form is valid() and if the username!==”” and then i am posting the form with ajax , else i am popping a dialog with the login page. The form submition is working fine when a user is logged in.

The problem is that i cannot figure out how to post the form after the user is logged in in the login dialog.

here comes the code :

    $('#MyForm').submit(function(event){
     event.preventDefault();


     var username=document.getElementById('loggedin').value;
     if($('#MyForm').valid() && username!=="" ){
     var serializeddata=$("#MyForm").serialize();



      $.ajax({
    type: "POST",
    url: "formsubmition", // The urls are in CI format
    contentType: "application/x-www-form-urlencoded;charset=UTF-8",

    data: serializeddata,
    dataType: "html",
    success: function(data) {
        $('#message_ajax_anaz').html(data);
                    }
                })




     }else if($('#MyForm').valid() && username==""){

      $("#loginpop").load("login").dialog();


     } 
     });

the login page ajax code:

$('#login').submit(function(event){
     event.preventDefault();

     var dataser=$('#login').serialize();
      $.ajax({
    type: "POST",
    url: "login",
    contentType: "application/x-www-form-urlencoded;charset=UTF-8",

    data: dataser,
    dataType: "html",
    success: function(data) {
        $('#message_ajax').html(data);
                    }
                })

And the above is working fine in the dialog, i can login normally.

Now How can i return in the $(‘#MyForm’).submit(function
with the user now as logged in ,also without having to fill the form again?

Just figured out a way
I hope it helps more people.

I initialized dialog outside the submit function :

    $("#loginpop").load("login").dialog({
        autoOpen:false
    })

then in changed my else statement :

    else if($('#MyForm').valid() && username==""){

  $("#loginpop").dialog('open');

And in my login ajax success function i added :

    $("#loggedin").val(data); // Changed the value of the hidden input with the username value on the fly. data contains the username

        $('#MyForm').submit();
        $('#loginpop').dialog('close');

Now everything is working and my form is submiting after the loggin 🙂

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

    https://stackoverflow.com/a/2276477/753676 would be much easier.

    http://api.jquery.com/serialize/

    You can store it also with cookie.js (and delete the cookie after submission) and can submit it then directly

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

Sidebar

Related Questions

Here's a scenario that I am working on : Right now we have a
Here is my scenario. I have a working login form that functions correctly. I
I am struggling working with large numpy arrays. Here is the scenario. I am
Here is the scenario: In my working directory, I have a number of files
Here is the scenario. I have a working VSX package Proof of Concept that
I had a simple working (ASP.NET) Scenario here: 3 asp:RadioButtons that each have OnCheckedChanged
I am not sure if this can be done, but here's the scenario. I
Here is a scenario. I am working on a small project and in this,
I've already read this but it doesn't answer to my question. Here's my scenario:
Here's my scenario - I am working with SL3 (and WCF Data Services) and

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.