Phonegap app unable to process AJAX post request, functions properly in browser

My AJAX request is encountering issues specifically when tested on the Phonegap App using iOS10.

The code I am working with is as follows and functions perfectly in a browser:

if($.trim(firstname).length > 0 & $.trim(email).length > 0 & $.trim(password).length > 0) {

            console.log("input checked");

            $.support.cors = true;
            $.ajax({
                type: "POST",
                url: "http://my-server.com/signup.php",
                data: dataString,
                crossDomain: true,
                cache: false,

                beforeSend: function(data) {
                    console.log("connecting to server");
                },

                //display success/fail message - put something in data on server
                success: function(data, textString, xhr) {
                    if(data == "success") {
                        localStorage.login = "true";
                        localStorage.email = email;
                        mainView.router.loadPage("swipe.html");
                    } else if(data == 'exist') {
                        myApp.alert("Account already exists", "Login Failed");
                    }
                },

                error: function(xhr, ajaxOptions, errorThrown) {
                    console.log("error msg: ");
                    console.log(xhr);
                    console.log(errorThrown);
                    myApp.alert("Unknown error, please try again", "Login Failed");
                },

                complete: function(data) {
                    if(data.readyState == "0") {
                        console.log("unsent");
                    } else if(data.readyState == "4") {
                        console.log("done");
                    }   
                }

            });
        } return false;
    }

I have ensured that my config.xml file is configured according to previous recommendations:

<plugin name="cordova-plugin-whitelist" />
<access origin="http://my-server.com" />

etc...

Disabling Apple's App Transport Security is not an option since I am only testing the app on a Phonegap server and the Phonegap App itself.

Could ATS be blocking AJAX requests to different domains from the Phonegap App? It seems like Phonegap would need to allow access to all domains, which might not be permissible for the app store!

This is my hypothesis regarding the issue. Any suggestions or alternative solutions?

Answer №1

One effective approach for enhancing the functionality of new iOS apps is to transition the backend to https...

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

The Strapi plugin seems to be encountering an issue as the API is not reachable, leading to a

In an attempt to create a custom API in Strapi backend, I developed a plugin called "test" for testing purposes. However, when trying to access the test response in Postman, it displays a 404 error stating that it is not accessible. Let me provide you wit ...

A guide on invoking a spring controller method using ajax

Below is the Controller method snippet: @RequestMapping( value={"/home"},params="userAction=loadHomePage",method=Request.POST) public String viewPage(@ModelAttribute("dataForm") formData, Model model,HttpServletRequest req)throws Exception{ ... } Can any ...

Consistent user interface experience for both Electron and browser users

Can the same index.html file be used by both an Electron process and a browser like Chrome? I have created an app that has its own Hapi server to handle HTTP requests to a database, which is working fine. However, when I try to serve the index.html file f ...

How to access a $scope variable in the same Angular controller function from outside the function

As a newcomer to AngularJS, I have a question about accessing my $scope variable from an outside function within the same controller. How can I achieve this? Below is the code snippet: .controller('RekapCtrl', ['$scope', '$timeout ...

React Native: Having trouble opening the date picker

I'm encountering an error when trying to activate the date picker, but I'm not sure why it's happening. Any assistance would be greatly appreciated. The error message is as follows: "value.getTime is not a function. (In 'value.ge ...

Troubleshooting Issue with Internet Explorer failing to update Asp.Net MVC3 Partial View

I am experiencing an issue with a page that includes a div for a partial view loaded via an ajax request. $.ajax({ url: 'CompleteSessions', success: function (data) { var selector = $('#complete-session-sect ...

Incorrect configuration file for karma

To simplify the configuration of the karma config file, I have utilized variables to store specific parts of the path. var publicfolder = "public" var mypath = "packages/vendor/package/"; files: [ publicfolder+'/assets/libs/jquery/dist/jquery.js&a ...

Looking to retrieve the text content of an element using jQuery?

My goal is to use jQuery mobile to transfer a user to a linked page when they click on an <li> element, and then display an alert with the text of the list element they clicked. However, my current implementation only shows an empty alert box. < ...

Sending a JSON array to a WebMethod

I encountered an issue when attempting to convert an object to a JSON array as a string, resulting in an Internal Server Error. Fortunately, the GetServerTime method is functioning properly. My goal is to send an array of objects to the server and conver ...

Tips for storing and recalling a 24-hour countdown timer using Local Storage

I'm new to JavaScript and I have a 24-hour countdown timer that resets on page reload. However, I want to use LocalStorage to save the starting progress so that it continues running even if the page is closed or refreshed. The goal is for the timer to ...

The issue with Firebase's real-time database is that data constantly gets overwritten within a single node

Having an issue with writing data to my Firebase realtime database. Below is the code I am using: firebase.database().ref("ac/0/").set(null); firebase.database().ref("ac/0/").once('value', function(snapshot){ for(var i=0; ...

Activate Popover with Hover and simply click anywhere to dismiss

Currently utilizing Bootstrap 4 and intrigued by the popover feature that activates on hover and closes when clicked anywhere. I'm also interested in making links functional within the popover. Any suggestions or tips on how to achieve this? $(doc ...

Issue with PassportJs not forwarding users after successful authentication

I'm facing some challenges with implementing Passport for authentication. I have set up my signup strategy in the following way: passport.use('local_signup', new localStrategy({ usernameField: 'username', passwordField:&apo ...

Learn about Angular8's prototype inheritance when working with the Date object

In my search for a way to extend the Date prototype in Angular (Typescript), I stumbled upon a solution on GitHub that has proven to be effective. date.extensions.ts // DATE EXTENSIONS // ================ declare global { interface Date { addDa ...

It is not possible to invoke a function within the AJAX success method

When trying to display an error message in my notify (toast) div using jQuery in Ajax success, I am encountering difficulties. Despite decoding the response from the URL properly, only .show() and .hide() functions seem to work. Although I have used conso ...

Issue with Slider Width in WP 5.6 editor and ACF Pro causing layout problems

Is anyone else experiencing a specific issue after updating to WP 5.6? Since the update, all my websites are facing problems with rendering a Slick Slider in the Block Editor. Interestingly, everything looks fine on the front-end. The root of the problem ...

Tips for utilizing import alongside require in Javascript/Typescript

In my file named index.ts, I have the following code snippet: const start = () => {...} Now, in another file called app.ts, the code is as follows: const dotenv = require('dotenv'); dotenv.config(); const express = require('express' ...

The method .makePerspective() in THREE.Matrix4 has been updated with a new signature. Make sure to refer to the documentation for more information

Attempting to run a functional three.js code using release 119 of three.js (instead of r79) has resulted in an error being thrown by the previously functioning code: THREE.Matrix4: .makePerspective() has been redefined and has a new signature. Please check ...

In React JS, the data from my response is not being saved into the variable

My goal is to store the response data in the variable activityType. Within the useEffect function, I am iterating over an API based on the tabs value. The API will return a boolean value of either true or false. While I can successfully log these values ...

Implementing server-side validation measures to block unauthorized POST requests

In my web application using angular and node.js, I am in the process of incorporating a gamification feature where users earn points for various actions such as answering questions or watching videos. Currently, the method involves sending a post request t ...