Phonegap app developer encounters issue with sending ajax requests

Recently, I encountered an issue with Ajax in my Phonegap development. Previously, it worked perfectly but now when I call the Ajax function, nothing happens. Here are the steps I have taken to troubleshoot:

1) I edited the config.xml file and added the following lines:

<access origin="*" />
<allow-intent href="http://*/*" />
<allow-intent href="https://*/*" />

2) I made changes to the AndroidManifest.xml file as follows:


    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
    <uses-permission android:name="android.permissions.NETWORK_ACCESS" />

3) Switched from using JSON to JSONP, which resulted in a 404 error.

4) Verified that URLs and parameters are correct as they were before, ruling out any issues here.

5) The APK build is functioning properly on all Android devices.

6) Attempted to resolve the problem by re-installing the Phonegap app and resetting the Android device to factory data.

7) Below is an example of my Ajax code:

app.ajax = {

load: function(method, url, data, onSuccess) {

    var beforeSend = function() {
        $('body').append($('<i class="loading-icon"></i>'));
    };

    var onComplete = function() {
        $('.loading-icon').remove();
    };
    var onError = function(jqXHR, textStatus, errorThrown){
      console.log(jqXHR);
    };
    $.ajax({
        method: method,
        url: url,
        data: data,
        beforeSend: beforeSend,
        success: onSuccess,
        complete: onComplete,
        error: onError
      });
}};

8) Node version: v0.10.25 Cordova version: 5.1.1

Answer №1

Hello @KENMAN143, From what I can see, on #3 it clearly indicates 404 (which means the file is not found). Assuming you are handling the event deviceready correctly since you've done this before, the issue must be with the NEW plugin required for whitelist. This detail can easily be overlooked as it was not mentioned in the blog but rather posted in the forum.

For more information on upgrading to cli-5.1.1 on PGB, refer to:

You may also find other important topics on my blog:
(Official) Messages from Phonegap Build Technical Support in the Forum

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

Guide to implementing personalized validation for an angular component

In my Angular component, I am looking to implement a custom input validator. However, I am facing an issue while trying to access the ngModelController in the $onInit function. It seems that the form is not populated at this stage. Strangely, in the sendEm ...

Guide on implementing ACCEPT_SINGLE_VALUE_AS_ARRAY in Jackson for deserialization with annotations

Is there a way to apply annotation to a List property within a class to utilize the ACCEPT_SINGLE_VALUE_AS_ARRAY feature in Jackson? I am using Spring and encountering the following exception: nested exception is com.fasterxml.jackson.databind.JsonMap ...

jq displaying the name of the variable instead of its value in the written text

Currently, I am working on a bash script to modify a json template by replacing specific field values with arguments passed to my script. To achieve this, I am attempting to utilize jq for the editing process. However, my code is not substituting the --arg ...

Can you effectively link together AngularJS promises originating from various controllers or locations?

Attempting to explain in as much detail as possible, the configuration file config.js contains the following code snippet: .run(['$rootScope', '$location', 'UserService', 'CompanyService', function($rootScope, $loca ...

Is it possible to dynamically evaluate the fs argument?

When I tried to run npm run dev, I encountered the following error: An error occurred while attempting to evaluate the fs argument statically [0] 50 | // Read file and split into lines [0] 51 | var map = {}, [0] > 52 | content = fs.read ...

Ensuring form field accuracy through server-side validation using Ajax - Mastering the art of Ajax

I am in need of implementing Ajax to validate my form fields, currently I have a javascript validation set up. Is it possible to reuse my existing javascript code and integrate Ajax for form validation? HTML Form <form method="post" action="ajax/valid ...

Guide: Implementing Paginated Search with Azure Search in PHP

I'm presenting a snippet of PHP code for reference: public function getListFromAzure($searchParameter, $categoryList, $request){ $jobListingManager = $this->get('recruitday.model_manager.job_listing'); $url = $jobListingManager- ...

Dynamically load modules within an AngularJS application

Is there a way to dynamically load module scripts? I have 2 JS files: module1.js (function() { var mod = angular.module('module1', []); .... })(); This is the second one: module2.js (function() { var mod = angular.module('m ...

Is there a library available for parsing JSON into a Dictionary of String-Object pairs in .NET?

I am looking for a way to convert a JSON string representing an object into a property bag (similar to a Dictionary) that I can utilize in C#. For example, if I have the following string: { "id":1, "name":"some name", "some parameter":2 } I aim to cre ...

Encountering an error while setting up the object spread operator Babel plugin for ES201

Exploring the possibilities of the new ES2018 spread operator for objects led me to discovering a promising NPM package: babel-plugin-transform-object-rest-spread Here's a glimpse of my package.json: // Scripts section "scripts": { "dev": " ...

Mastering the art of utilizing CallBackScript effectively in Wicket 6.x

Back in the days of Wicket 1.x, I utilized an AjaxEventBehavior to implement a CallBackScript that provided me with the mouse coordinates. Here's a snippet of what I used: (getEventX() and getEventY() are JavaScript Functions) myObject.add(new Aj ...

Is it possible to send a ternary expression inside a component as a prop based on whether the condition is true or false?

Is it possible to include a ternary expression inside a component and pass it as a prop depending on whether the condition is true or false? <ExperienceList onUserToggle={this.onUserToggle} jobs={this.state.jobs[this.state.value]} { th ...

Transforming JSON or dictionary data into a flattened string format using special marker symbols

Consider the following input: {'example_id': 0, 'query': ' revent 80 cfm', 'query_id': 0, 'product_id': 'B000MOO21W', 'product_locale': 'us', 'esci_label': &apos ...

Update the referral URL using an AJAX call

Trying to set the referer page on an ajax request has been unsuccessful so far. I attempted to implement this in a local html file with the main url being on a different domain. $.ajax({ url: "{{main url}}", dataType: "json", beforeSend: function(xh ...

Exploring the issue of $scope variable changes not reflecting in ng-show elements in AngularJS

I am in the process of creating a website that includes a video element. For those interested, here is a link to the code for my page on Plunker: http://plnkr.co/edit/5NUnZ2KET1apWwxMxjex?p=preview The video on the website utilizes the html5 video tag, a ...

Press the designated button located within a table's td element to retrieve the values of adjacent td elements

I need to implement a functionality where clicking a button within a <td> element will retrieve the values of other <td> elements within the same row (<tr>). Here is the current implementation: $(document).ready(function(){ ...

Upon redirection, my JavaScript codes cease to function properly and require a page refresh to resolve

Upon redirecting to another page with included JS codes, my main.html does not function properly until I refresh the page. What steps can be taken to resolve this issue? 0.html <body data-theme="b"> <div class="p2" data-role="page" id="p2"> ...

Develop a Rails object using AJAX and JavaScript

Within a music application built on Rails, I am attempting to monitor plays for tracks by artists. This involves creating a unique play object each time a visitor plays a track on the site. These play objects are assigned their own distinct IDs and are ass ...

To insert a <div> element within a <tr> element while preserving the exact position of the <tr> tag - here's how you can do it:

I have a challenge with my table where I need to add a green progress bar in the form of a div element within a tr. The width of this progress bar should change dynamically from 0% to 100%, reflecting the current runtime of the video associated with that p ...

Conceal the Submit button upon completing the form submission using the load method

When creating a form and sending a request to another page, I use the following code: $(document).ready(function() { $("#send").click(function() { var text = $("#text").val(); var email = $("#email").val(); $("#exp").load("sendmail.php",{text: ...