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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T03:41:18+00:00 2026-05-26T03:41:18+00:00

So my goal was to have a function in my jQuery code, that allowed

  • 0

So my goal was to have a function in my jQuery code, that allowed me to do case statements that then allowed me to do what I needed with each form, without having to re-type the whole post function.

UPDATE my fix is at the very bottom of this question

e.g.

    function fetch(e,formstring)
{

    $.ajax({
      type: 'POST',
      url: 'system/classes/core.php',
      data: formstring,
      dataType: 'json',
      contentType: "application/x-www-form-urlencoded;charset=utf-8",
      success: function(data){
          $.each(data, function(i, obj) {

               switch (e) { 
                 case 1:
                  $.each(obj, function(key, val) {
                     alert(key+" - "+val);
                  });
                 break;
                 case 2:
                    alert("sucker");
                 break;
                 case 3:
                 //LoginSript

                    $('#rightheader').html(obj.code);
                 break;
                 case 4:
                 //WelcomePage/Signup
                    $('#window').html(obj.code);
                 break;
               }
         });
      },
      error: function(data){
      $.each(data,function(i,myinfo){
            alert(i);       
          });
      }
    });
    return false;
}

While fetching data seems to work, submitting forms seems not.

$(function() {

    $("form#login").submit(function(){
        shownotify(1,"Please hold we are login you in.");
        fetch(1,$(this).serialize());   
    });
});

I thought I was doing everything right.

just also so you can see here is the show notify function too.

    function shownotify(e,msg)
{
    if(e==1){$('#notify').show();};
    if(e==2){$('#notify').hide();};

    $('#notifyheader').html("Please Hold");
    $('#notifytext').html(msg); 
}

I am wondering if I have an error, or am I doing this wrong?

  • 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-26T03:41:19+00:00Added an answer on May 26, 2026 at 3:41 am

    The way I fixed the error was by setting a setTimeout function around the $(function(){})

    setTimeout(function(){
    $(function() {
    
        $("form#login").submit(function(){
            shownotify(1,"Please hold we are login you in.");
            fetch(2,$(this).serialize());   
        });
    });
    },1000);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following jquery code: $(.rotateNews).load(/load_news.php); var refreshId = setInterval(function() { $(.rotateNews).load('/load_news.php?newsID='); },
My goal is to have a jQuery datepicker pop up when the user clicks
My ultimate goal is to have a menu that adds a class to the
I have the eventual goal of determining that a particular database on a particular
I have a basic form that I am using as a dummy to test
I'm having trouble getting Jquery .closest() to work. Here's my code, it's simple and
I have a simple javascript (JQuery based) method that does some css magic to
My goal is to each div with a class of main to have a
I have some code that when a user clicks on a link Add Comment,
Does jQuery have a method to determine if an argument passed to function is

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.