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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T03:13:51+00:00 2026-06-06T03:13:51+00:00

Hi all, I have in my js file: function sendDataToPhp() { theUrl = ‘myfile.php’;

  • 0

Hi all,

I have in my js file:

function sendDataToPhp()
{
  theUrl = 'myfile.php';
    params = '';
    params += 'function=sendData';

    params += '&myfield='+someVariableForMyField;
    $.ajax ({
        url: theUrl,
        data: params,
        type: "POST",
        async:false,
        success: function (data, textStatus)
        {    
        }
    }); 

}

Then in myfile.php

if (isset($_REQUEST['function']))
    {
        $function = $_REQUEST['function'];

    }  


    switch ($function) {
        case 'sendData':
        //code
        break;
        default:
       //code
}

With this I’m sending the code flow to the sendData case of the switch.

Now Inside the success, in the ajax() I need to send the code flow to the default case of the switch. How can I do that?

Thanks a million!

  • 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-06T03:13:52+00:00Added an answer on June 6, 2026 at 3:13 am

    The way Switch works is if there isn’t a matching CASE then it goes to DEFAULT case … so perhaps you can provide function=IdontExistFunction in your ajax call … OR if there is piece of code in DEFAULT you want to run then best to separate it and make it a function so that you can call from anywhere as required.

    BTW – There is GOTO statement available too – not sure if you can make use of it in your case http://php.net/manual/en/control-structures.goto.php ?

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

Sidebar

Related Questions

So I have a function call classifier that basically check all text file in
I have defined a searchform in the Page.php file function AdvancedSearchForm() { $searchText =
I have a file called function.js which has all my jQuery for my aplication
I have this code in a .html.erb file: <script src=http://connect.facebook.net/en_US/all.js#xfbml=1></script> <script> FB.Event.subscribe('edge.create', function(response) {
I have a simple JavaScript file that has three jQuery $document.ready functions. All three
I have file locale/es/LC_MESSAGES/django.mo (and .po), ran makemessages and compilemessages. Definitely all messages are
How do I find the current filename, if all I have is the file
I have a file that I include on all my webpages that contains the
I have a file produced by strace which contains all the system calls. Now
i have one file for the header which is included on all of my

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.