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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T12:13:05+00:00 2026-06-04T12:13:05+00:00

I have a multi-languages Jquery Mobile site (Backend is Coldfusion8/MySQL). I’m using a generic

  • 0

I have a multi-languages Jquery Mobile site (Backend is Coldfusion8/MySQL).

I’m using a generic Ajax-form-poster to “pass” data to the server, which I’m calling throughout my script passing along the respective AJAX parameters like so:

One of my Ajax callers:

$(document).on( "pagebeforechange.lang", function( e, data ) {
    if (typeof data.toPage === "string") {
        if (data.toPage.indexOf("?sprachwechsel=") > -1) {
            // stop
            e.preventDefault();
            // get the language from clicked link
            var viewSwitch  = $.mobile.path.parseUrl( data.toPage ).hash.replace( /.*sprachwechsel=/, "" ),
               service = "services/form_service_user.cfc",
               method = "process",
               returnformat = "JSON",
               targetUrl = "",
               // fake a form
               formdata = "form_submitted=lang&viewSwitch="+viewSwitch+"&method="+method+"&returnformat="+returnformat,
               // create the success handler
               successHandler = function(e, data) {
                   data.options.reloadPage = true;    
                   data.options.allowSamePageTransition = true;
                   data.options.transition = "fade";
                   // reload page with new language
                   $.mobile.changePage( window.location.href, data.options);    
                   };
            // hand over to Ajax
            ajaxFormSubmit( form, service, formdata, targetUrl, successHandler );
            }
         } 
    });
};

All callers go to a central AJAX form submit, which looks like this:

var ajaxFormSubmit = function ( form, service, formdata, targetUrl, successHandler ){
    $.ajax({
        async: false,
        type: "post",
        url: service,
        data: formdata,
        dataType: "json",
        success: function( objResponse ){
            if (objResponse.SUCCESS){
                alert("success");
                successHandler;
            } else { }
        },
        error: function (XMLHttpRequest, textStatus, errorThrown) { 
        }
    });
}

I’m not submitting forms all the time, but also am trying to use this way to update session settings such as the language to display.

My questions:
If I’m capturing a Jquery Mobile changePage on the pagebeforechange event, then preventDefault, perform an AJAX call and want to fire a new changePage transition from the success handler using the original event and data objects… how do I pass them through to to the success handler?

Side Question: Is this approach viable or should this be done in an easier way? I need to reset views and langauges quite a bit and I want to keep the app running and not have to hard re-load pages all the time, just to get a single coldfusion variable set from “EN” to “DE”.

Thanks for help!

  • 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-04T12:13:06+00:00Added an answer on June 4, 2026 at 12:13 pm

    Unless I misunderstand your question, your success handler already has access to the data object and e event object as this is ‘closed into’ that function. Only problem being you are adding them as expected parameters to you success handler function. Take them away and you will have access to the data returned from the ajax call and these other two variables. Like so…

    $(document).on( "pagebeforechange.lang", function( e, data ) {
        if (typeof data.toPage === "string") {
            if (data.toPage.indexOf("?sprachwechsel=") > -1) {
                // stop
                e.preventDefault();
                // get the language from clicked link
                var viewSwitch  = $.mobile.path.parseUrl( data.toPage ).hash.replace( /.*sprachwechsel=/, "" ),
                   service = "services/form_service_user.cfc",
                   method = "process",
                   returnformat = "JSON",
                   targetUrl = "",
                   // fake a form
                   formdata = "form_submitted=lang&viewSwitch="+viewSwitch+"&method="+method+"&returnformat="+returnformat,
                   // create the success handler
                   successHandler = function(response) { // response is data from server
                       data.options.reloadPage = true; // data is from outer function
                       data.options.allowSamePageTransition = true;
                       data.options.transition = "fade";
                       // reload page with new language
                       $.mobile.changePage( window.location.href, data.options);    
                       };
                // hand over to Ajax
                ajaxFormSubmit( form, service, formdata, targetUrl, successHandler );
                }
             } 
        });
    };
    

    Now you can just pass the handler function to the ajax call.

    var ajaxFormSubmit = function ( form, service, formdata, targetUrl, successHandler ){
        $.ajax({
            async: false,
            type: "post",
            url: service,
            data: formdata,
            dataType: "json",
            success: successHandler,
            error: function (XMLHttpRequest, textStatus, errorThrown) { 
            }
        });
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using 'rails3-jquery-autocomplete' gem, but it doesn't have multi column search, but there is
I have this application that I want to support multi languages. I thought the
I have a problem with Drupal uploads path when in a multi language site.
I have a multi-tenant application and I'm experimenting with using the i18n gem to
I'm setting up a multi-language using gettext. Since all text from other languages are
I am making a multi-lingual (computer languages) notepad in WinForms. I have a menu
I have strings that are multi-lingual consist of both languages that use whitespace as
making a multi-language site with codeginiter. I have created two folders. One for french
I have a problem with multi-languages with Spring on project EgovFramework. My problem cannot
I have a multi language site, what is the way to proceed for good

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.