Encountering a 404 error in an AngularJS app within Cordova on Android

Currently, I am working on an android application using Cordova and AngularJS (front-end framework OnsenUI). Below is the code snippet for my GET request to retrieve data from the server:

$http.get(url+"getlotterylist").then(function(msg){
        $scope.loading=false;
        $scope.items=msg.data;
    },
    function(err){
        alert("error"+JSON.stringify(err));
          console.log("Error"+JSON.stringify(err));
        }
    );

SITUATION 1

When testing the app in a browser, the GET request works perfectly fine.

SITUATION 2

After building the app for the Android platform and importing it into Android Studio, the HTTP GET request encounters the following error:

{"data":"","status":404,"config":{"method":"GET","transformRequest":[null],"transformResponse":[null],"url":"http://example.com?action=getlotterylist","headers":{"Accept":"application/json, text/plain, /"}},"statusText":"Not Found"}"

I have also enabled CORS in my PHP script:

<?php
  header("Access-Control-Allow-Origin: *");
 //api request response
?>

What could be causing this error specifically when running the app on a mobile phone?

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

When utilizing KineticJS on a canvas that has been rotated with css3, the functionality of the events appears to be malfunctioning

Currently, I'm working on a rotating pie-chart widget using Kineticjs. However, I have run into an issue where the events don't seem to function correctly when drawing on a rotated canvas element (with the parent node being rotated 60deg using CS ...

How can Angular incorporate JSON array values into the current scope?

I am currently working on pushing JSON data into the scope to add to a list without reloading the page. I am using the Ionic framework and infinite scroll feature. Can someone please point out what I am doing wrong and help me figure out how to append new ...

When you make a POST request to an express API, the properties are not clearly defined

Just getting into Vue.JS and experimenting with creating a basic MEVN to-do list app for practice. I keep encountering an issue when trying to send a POST request to my express server, receiving the error message: TypeError: Cannot read properties of unde ...

Room.kt - The Database_Impl you are looking for cannot be found

I've been facing issues while trying to implement a Database in my new app. Despite numerous searches, I couldn't find a solution, so I'm reaching out here with my problem: FATAL EXCEPTION: main (Ask Gemini) Process: com.basic.app, PID: ...

transform the binary information into legible text

ETCD dashboard displays a binary string as shown below: var _deps_js = "\x1f\x8b\x08\x00\x00\x09\x6e\x88\x00\xff\xcc\xbd\x7b\x77\xdb\x46\xb2\x2f\xfa\xff&bs ...

Having trouble with form validation in React.js? Wondering about the best ways to compare two fields? Let's

It's important to ensure that users enter the same email in both the email and confirmEmail input fields. I've experimented with a few methods, but I'm not certain of the best approach. Is there a simpler way that I might be overlooking? In ...

Populate the auto complete input box with items from a JSON encoded array

I have a PHP file that returns a JSON encoded array. I want to display the items from this JSON array in an autocomplete search box. In my search3.php file, I have the following code: <?php include 'db_connect.php'; $link = mysqli_connect($ho ...

What could be causing the read-only error in my presentation?

My website has always had a small slider that worked perfectly, but now an error message keeps popping up: Error: "myIndex" is read-only This is the JavaScript code in question: const myIndex = 0; carousel(); function carousel() { let i; const x = ...

Employ a unique filter within the controller of your AngularJs directive

Current Situation I currently have an array of users with their information and I am using ng-repeat along with a custom directive to create HTML user cards. The scope for each card is specific to the individual user. Within the user model, there is a v ...

Transferring Variables from WordPress PHP to JavaScript

I have implemented two WordPress plugins - Snippets for PHP code insertion and Scripts n Styles for JavaScript. My objective is to automatically populate a form with the email address of a logged-in user. Here is the PHP snippet used in Snippets: <?p ...

Executing PHP include statement with ajax: A step-by-step guide

I am trying to achieve a feature on my website where when a button is clicked in the index.php file, an AJAX request will load about.php and display it inside a div tag within index.php. Unfortunately, my current code doesn't seem to be working as exp ...

Personalized Svelte interface Slider tag

I am trying to customize the label of a smui/slider in a tick marks and discrete slider. While I found instructions on how to do this using material web components at https://github.com/material-components/material-components-web/tree/v13.0.0/packages/mdc- ...

I'm a bit uncertain about the best placement for my progress bar component during the API call

Trying to grasp material ui I managed to implement the progress bar. Struggling with loading it until my data is fully loaded. Uncertain about where to place my progress bar component. Could you guide me on how to resolve this issue during API calls, so I ...

I am encountering issues with my PostCSS plugin not functioning properly within a Vue-cli 3 project

I developed a custom postcss plugin that was working perfectly according to the postcss guidelines until I tried to implement it in a real project. For reference, here's the plugin on GitHub My goal is to integrate it into a Vue-cli app using Webpac ...

Obtaining the initial value from an Observable in Angular 8+

Initially, I have a page form with preset values and buttons for navigating to the next or previous items. Upon initialization in ngOnInit, an observable provides me with a list of 3 items as the starting value - sometimes it may even contain 4 items. Ho ...

Error in bundle.js at line 25872: A critical error has occurred due to excessive re-renders. React has imposed a limit on the number of renders to avoid an infinite loop. Learn how to resolve

I am currently working on CRUD operations to update data. How can I avoid this error: "Too many re-renders. React limits the number of renders to prevent an infinite loop?" import React,{useEffect,useState} from 'react'; import { NavLink } from ...

The perplexity caused by unescaped HTML and line breaks

I have created a platform similar to a forum, where users can input various strings such as: <<<<< >.< and so on. It is essential for me to maintain the formatting of new lines. Additionally, I need to condense multiple new lines in ...

The specified property cannot be found within the type 'JSX.IntrinsicElements'. TS2339

Out of the blue, my TypeScript is throwing an error every time I attempt to use header tags in my TSX files. The error message reads: Property 'h1' does not exist on type 'JSX.IntrinsicElements'. TS2339 It seems to accept all other ta ...

Leveraging jest.unmock for testing the functionality of a Promise

I've implemented Auth0 for managing authentication in my React App. Below is the code snippet I am trying to test: login(username: string, password: string) { return new Promise((resolve, reject) => { this.auth0.client.login({ ...

Struggling to set a variable during the loading of a page in AngularJS

I'm facing an issue with initializing a variable called showName when the page loads. It was working perfectly fine with just Angular, but as soon as I integrated it with Rails (using embedded Ruby tags), the text field and save button are not being h ...