Creating web pages using JavaScript

I have developed a front-end JavaScript page that collects user data and stores it in a variable. My web application functions like a Facebook-type platform, but it is actually a decision support system based on fuzzy logic.

My question is, will my JavaScript page be shared by all users or will a new page be created for each user who requests a page utilizing that JS script?

This is important to me because I need to store some data globally within the JS page, which is accessed by different JS functions on the same page. If a single JS page is shared among all users, concurrency may impact the values in that global variable.

JavaScript Code:

var Data_obj = new Object();   // Global variable

$(document).ready(function () {
    docReady();
});

function docReady() {
    // Preventing # links from scrolling to the top
    $('a[href="#"][data-top!=true]').click(function (e) {
        e.preventDefault();
    });

    // Chosen - enhances select options
    $('[data-rel="chosen"],[rel="chosen"]').chosen();

    // Tabs functionality
    $('#myTab a:first').tab('show');
    $('#myTab a').click(function (e) {
        e.preventDefault();
        $(this).tab('show');
    });

    // Handling events for specific elements within the table
    $('#applicant_table tbody').on("click",".cv_info",function (e) {
        e.preventDefault();
        Cv_path=$(this ).attr("cv_path");
        $("#cv_data").html('<object data="'+Cv_path +'" type="application/pdf" width="450" height="460"></object>');
        $('#myModal_cv').modal('show');
    });

    $('#applicant_table tbody').on("click",".msg",function (e) {
        e.preventDefault();
        Data_obj.E_mail=$(this ).attr("email");//Data fetch and stored in object
        Data_obj.name=$(this ).attr("name");
        $('#myModal_email').modal('show');

    });

    $('#applicant_table tbody').on("click",".setting",function (e) {
        e.preventDefault();
        Data_obj.can_id=$(this ).attr("can_id");
        alert(can_id);
        //$('#myModal_setting').modal('show');
    });
}

// Event listener for filter option change
$( "#filter_option" ).change(function() {
    $("#applicant_table tbody").empty();
    $( "#filter_option option:selected" ).each(function() 
   {
        var van_id=$("#Job_title option:selected").val();   
        var Duration=$(this).val();
        if(van_id!="")
        {
            var Obj=new Object();
            Obj.duration=Duration;
            Obj.van_id=van_id;

              $.ajax({
                  type: "POST",
                  url: '/Arsenal/requritment/Update_Application_table',
                  contentType: 'application/json',
                  data: JSON.stringify(Obj),
                  success: function(Data){
                    for(var i=0;i<Data.length;i++)
                    {
                        data=Data[i];
                        if(data.can_id!=null)
                        {
                            var a='<tr><td><b>'+data.apply_date+'</b></td><td><b><i>'+data.name+'</i></b></td><td><b>'+data.phone+'</b></td><td><span class="label-success label label-default">New</span></td><td> <i class="glyphicon glyphicon-list-alt cv_info" cv_path="/Arsenal/requritment/getCv?can_id='+data.can_id+'"></i>  <i class="glyphicon glyphicon-envelope msg" email="'+data.e_mail+'"  name="'+data.name+'" ></i> <i class="glyphicon glyphicon-cog setting" email="'+data.e_mail+'"  can_id="'+data.can_id +'"></i></td></tr>';
                            $("#applicant_table tbody").append(a);
                        }
                    }
                }
            });
        }
    });
});

function Send_Message()
{
    alert(Data_obj.name);    // Retrieving data
    Msg_title=("#title_name").val();
    Msg_body=("#content_info").val();
    $('#myModal_email').modal('hide');
}

Answer №1

Each individual user, through their own HTTP request, will independently load and run your JavaScript code... meaning that the script will be unique for each user.

If you are looking to establish communication, whether it be with your server or other users, you will need to send data to the backend and potentially share that information with all users from the server. Many people utilize ajax for this purpose, and based on the existing ajax-calls in your code, it seems like you may already be doing that. However, it's not entirely clear.

If there is no need for communication between users, you have the option to store all user data in local storage or keep it in memory.

A more accurate response requires a more specific inquiry :)

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

In JavaScript/Node, the timezone of Date objects stored in dictionaries may be altered

To prevent complications with daylight saving time when working with dates, I always utilize UTC. As an illustration: new Date(2019,8,20, 9, 0) results in 2019-09-20T08:00:00.000Z new Date(Date.UTC(2019,8,20, 9, 0)) yields 2019-09-20T09:00:00.000Z -- thi ...

Organize array of objects based on the "dataPrin" field

I've been attempting to group this array by the "dataPrin" field for some time now, but without success. It's worth noting that there are two instances of the "dataPrin" field displaying the same date. My goal is to organize this array in a way ...

"Enhance your React project with dynamic filtering capabilities using Ant Design's Table

When attempting the code below, I encounter an error related to columns: { title: "Gruppe", dataIndex: 'group', filters: [ this.state.dropdownItems.map((item) => ({ text: item.group, value: item.group ...

Fundamental JavaScript feature experiencing functionality issues

Greetings, this is my debut in this space and I am encountering some challenges as a beginner in the world of coding. It seems that passing arguments to parameters is where I'm hitting a roadblock, or perhaps there's a simple detail that I'm ...

Utilize $http.get within a service/factory to retrieve a set of items

I am trying to utilize a http.get promise within an angularjs service, perform some manipulation on the retrieved collection, and then pass it back to a controller... My query is regarding the proper usage of $http.get() in a service to fetch and modify t ...

Sending data from TextBoxFor to controller with @Ajax.ActionLink in MVC

I’ve gone through numerous questions dealing with the same issue, yet none of them seem to solve my problem (or I’m completely missing the point). As the title suggests, I am attempting to transfer the value from a TextBoxFor to my controller using an ...

The AngularJS beginner routing application is malfunctioning and needs fixing

I've been diving into Angular JS but hit a roadblock with a basic angular routing program. I need some guidance on what's going wrong. If you want to check out the complete project code, visit my GitHub repository: https://github.com/ashpratap00 ...

How to Populate a List with Objects in Angular 2 using Typescript

Currently, I'm encountering an issue with adding data to a list using the following code snippet. labelListSelected: Label[]; onChange(object, flag){ if(flag==false){ this.labelListSelected.push(object); } console.log(this. ...

difficulty encountered when using the Angular delete method in conjunction with Express.js

I am trying to send a delete request to my Express server from Angular. remove: function (id) { return $http({ method: 'DELETE', url: '/users/delete/'+ id }) } In my Expr ...

Passing a function to a dynamically created child in React with an extra parameter

In my React project, I am looking to dynamically generate child components and have them trigger an onClick event from their parent or grandparent component. What I aim to achieve is the following flow: When rendering the parent component Pass a referenc ...

Update content dynamically with React by clicking a button

I am managing three distinct files. Nav.js var NavItem = React.createClass({ render: function() { return ( <li><a href="#">{this.props.name}</a></li> ); } }); var NavList = React.createClass({ render: function ...

Is there a way to ensure that the line numbers displayed for JavaScript errors in Chrome are accurate?

I suspect either my webpack configuration or my npm run dev script are causing the issue, but I'm unsure of what exactly is going wrong. While running my application in development mode, I encounter error messages like: Uncaught TypeError: this.props ...

Insert an array inside another array using JavaScript (jQuery)

I've been attempting to use the push() method within a loop to construct a data structure as shown below: var locations2 = [ ['User', position.coords.latitude, position.coords.longitude, 1], ['Bondi Beach', -33.890542, 151 ...

Using JavaScript regular expressions to restrict the characters allowed in an HTML text input field

I am new to Regex and just starting out with Javascript. I am attempting to require users to follow a specific pattern when typing in the textarea. The pattern should start with 'X' followed by 9 numbers. If the first character is not an 'X ...

How to share information between ES6 classes?

Recently, I decided to create a node/express app just for fun. One of the components I built is an ES6 class called 'TwitterClient.es6' that interfaces with the Twitter API to fetch data. Now, in my 'server.es6', which handles the route ...

When utilizing JSON data in node.js, the .find() method may return undefined

I am currently working on a node server and my goal is to display JSON data when a specific ID is clicked. I have configured a dynamic URL that will retrieve the data of the clicked video using parameters and then compare it with the data in the JSON file ...

Trouble with CSS animations persisting after switching classes

I implemented a toggle menu using the source code from my actual project to avoid any confusion:- div.btn-dropdown-options { font-family: "Haas Grot Text R Web", "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 14px; ...

jQuery Ajax allows scripts to be contained within a page, even if the page itself is empty

Utilizing jQuery ajax to display an HTML page that includes javascript functions, here is my code: function ChartBook() { $.ajax({ url: '/Charts/ChartBook', dataType: 'html', id: 1, ...

Issue with Material-ui autocomplete not updating its displayed value according to the value prop

My task involved creating multiple rows, each containing a searchable Autocomplete dropdown populated through an API, along with other fields. Everything was functioning perfectly until I encountered an issue when deleting a row from the middle. After dele ...

Generating and Retrieving Dynamic URL with Jquery

My web page named single-colur.html has the ability to handle various query strings, such as: single-colour.html?id=1 single-colour.html?id=2 single-colour.html?id=3 single-colour.html?id=4 The parameter id in the URL corresponds to an entry in a table c ...