The code functions perfectly on my local machine, however it is not cooperating on the HostGator server

A selection box based on values should appear in text fields,

The current code is functional in local host but not working on the hostgator server

For example, displaying country options based on the selected state and districts based on the selected state.

<script type="text/javascript>
        $(document).ready(function () {
            $('#state').on('change', function () {
                var stateID = $(this).val();
                if (stateID) {                   
                    $.ajax({                 
                        url: '<?php echo base_url(); ?>index.php/myform/ajax/' + stateID,
                        type: "GET",
                        dataType: "json",           
                        success: function (data) {        
                            console.log(data);
                            var title = [], metatags = [], description = [];
                            $.each(data, function (key, value) {
                                title.push(value.page_title);
                                metatags.push(value.page_metatags);
                                description.push(value.page_description);
                            });
                            $('input[name="city"]').val(title.join(','));
                            $('input[name="Metatags"]').val(metatags.join(','));
                            $('input[name="Description"]').val(description.join(','));
                        }
                    });
                }
            });
        });
    </script>

routes.php

   $route['myform'] = 'welcome';
    $route['myform/ajax/(:any)'] = 'welcome/myformAjax/$1'; 

welcome.php

 public function update() {
    $this->load->helper('url');
    $data['state_fetch'] = $this->Question_Insertion_Model->all_Pages_Display();
    $this->load->view('update', $data);
    }
    
    public function myformAjax($id) {
    $this->db->select('c.*');
    $this->db->where("s.page_id", urldecode($id));
    $this->db->join('kas_all_pages s', 's.page_id = c.page_fk');
    $result = $this->db->get('kas_all_pages_tags c')->result();
    echo json_encode($result);
    }  

Answer №1

To include the following code in index.php:

  • IMPORTANT: If you make modifications here, remember to update the error_reporting() code below */ $_SERVER['CI_ENV']='production';

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

Having trouble getting Vue.js hello world to display on the page

I am attempting to create a Hello World app following the Vue.js site's get started documentation. Everything seems to be in order, but only the HTML code is being displayed on the page. Vue version: 1.0.26 Below is the HTML code: <!DOCTYPE ht ...

What is the best way to send a variable using $.post in a JavaScript script?

My jQuery and Javascript code below is responsible for handling the ajax request: else { $.post("http://www.example.com", {email: val}, function(response){ finishAjax('email', response); }); } joi ...

Advantages of Using JSON for POSTing Data to a Server with jQuery

While browsing the internet, I've come across various examples of using jQuery to send AJAX POST requests with JSON encoded data to a server. I'm curious about why it's necessary to encode the data in JSON first. Wouldn't it be more eff ...

Having issues with using the class selector in SVG.select() method of the svg.js library when working with TypeScript

Exploring the capabilities of the svg.js library with typescript has presented some challenges when it comes to utilizing CSS selectors. My goal is to select an SVG element using the select() method with a class selector. In this interactive example, this ...

Searching for values using keys in Angular

Currently, I am working on a project using Angular where I need to store information based on specific identifiers. To display this information in the Angular application, I am pulling data for different identifiers and showing it on the screen. At the mo ...

The fixed left div and scrollable right div are experiencing issues with their alignment

I am having an issue with a section where the left div is fixed and the right div is scrollable. However, the content of the right div scrolls even before the scroll top reaches the section. My goal is for the right div to scroll only when it reaches the t ...

Using jQuery to pause execution until a function returns before proceeding

After updating to version 1.10.2, I encountered some issues with jQuery. Despite my attempts to find a solution, none of the methods I've tried have seemed to work. It's possible that I am missing something in my approach. Any assistance would b ...

web browser editing tool

Do you know which library was utilized to create this JSON editor? You can find it at . The editor efficiently checks the syntax and shows errors when necessary. ...

What is the best way to extract the text inside a div element based on the input value in a

I attempted to extract the innerText of a div along with the input values within it. For instance: <div> My name is Shubham, I work for <input type="text"/> for the last 5 years.</div> My objective is to retrieve all the text ...

showing text from chosen selection with an additional element included in the output

I could use some assistance with this code snippet. My goal is to showcase the options in the format: "Fried Rice = 10.000" as the outcome. However, the issue I am facing is that the select option box also contains the price. What I actually need is for th ...

Download files using AJAX in Laravel 5.6

I am faced with a challenge in my Laravel 5.6 REST API. Users have the capability to upload their files to a non-public folder. Now, I need to ensure that users can only download files if their JWT token is valid and they have the necessary privilege. H ...

Preventing a user with the same name as the one in the table from being added by utilizing a jQuery contains check proved

Check out my fiddle here: http://jsfiddle.net/jd5pgdz2/4/ I encountered an issue when attempting to add a user with the same name as one already in my table (the displayed users are static in the HTML). Despite using 'contains' to check if the u ...

How is the server architecture typically designed in a node.js application?

Currently, I am developing a node.js application using socket.io and I'm seeking advice on how to structure the folders properly. The files that I have in my project include: Server.js package.json Additionally, I have: Client.js Index.html Incl ...

Adjusting the margins of jQuery mobile buttons

I seem to be stuck on a simple error that is causing me to spin my wheels. Take a look at the following jqm (version 1.3) view (in haml) #main-header{'data-role' => 'header'} #main-content{'data-role' => 'content ...

Encountering difficulties when attempting to upload to Google Cloud using a signed URL

Seeking help to troubleshoot why the video upload is not working as expected. I am able to successfully connect to my bucket using a signedURL, but when trying to upload the video, it's not functioning properly. const submitVideo = async () => { ...

Guide to detecting touch events in React Native

Is there a simpler way to listen for touch events in a React Native view and perform actions in the callback? I've tried using Pan Responder and the onResponderGrant callback, but it feels like a workaround. Is there a more straightforward method, per ...

jquery ready function key event

When using AJAX to load elements on my page, I have a requirement where pressing Enter should move the focus to the next input, textarea, or select element. Some inputs also have a number formatting function applied, but the current solution runs multipl ...

Tips for implementing both an onChange and onSubmit event for a MUI TextField

I'm currently working with React and MUI and have created a form like the following: const handleUserInput = (event) => { set_user_input(event) } const handleSubmitForm = () => { if (user_input == 'help'){ ...

The $emit method in Vue seems to be ineffective when used on the parent component, yet it functions properly when used on the

I have a component called "register" which contains an event listener @submit.prevent inside the template, and I am using $emit to send the data. When I console.log within the method of the component itself, it works fine. However, when I try to access the ...

What causes the Object expected error in jQuery?

Looking for a way to demo horizontal collapse pane with a simple web page that includes html, css, and jquery. <html> <head> <script type="text/javascript" src="//code.jquery.com/jquery-1.10.1.js"></script> <title>Sa ...