PhoneGap Ajax call not working

I’m Trying to make an app that uploads Images. I use PhoneGap to build it for Android.

I can’t seem to get the AJAX call I use to upload the Images, working. My AJAX call is this:

     $.ajax({
        url: 'http://127.0.0.1:53827/api/v1/imageupload/uploadimage/' + i + '/' + i + '/veilingmeester',
        cache: false,
        type: "POST",
        processData: false,
        contentType: false,
        data: formData[i],


        headers: {
            'Access-Control-Allow-Origin': '*.*',
            'connect-src': 'http://localhost:53827'
        },
        success: function (data) {
            //met deze data moeten we nu een object aamaken voor de database
            Output(image[i]);

        },
        error: function (jqXHR, err) {
            LogError("error:" + err);
            LogError("jqXHR:" + jqXHR);
            LogError("jqXHR.status:" + jqXHR.status);
            LogError("jqXHR.statustext:" + jqXHR.statusText);
        }
    });

So I already searched around SF, but I can’t get it to work. My config.xml looks like this:

<?xml version='1.0' encoding='utf-8'?>
<widget id="com.dangoo.img" version="0.0.1" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
<name>Dangoo Pics</name>
<description>
    Upload plaatjes naar de Dangoo server. Vermakkelijk het proces van producten toevoegen!
</description>
<author email="rustenhovenmick@gmail.com" href="http://dangoo.info">
    Certigon Development Team
</author>
<content src="index.html" />
<plugin name="cordova-plugin-whitelist" version="1" />
<access origin="http://localhost:53827/*" />
<allow-navigation href="http://localhost:53827" />
<allow-intent href="http://*/*" />
<allow-intent href="https://*/*" />
<allow-intent href="tel:*" />
<allow-intent href="sms:*" />
<allow-intent href="mailto:*" />
<allow-intent href="geo:*" />
<platform name="android">
    <allow-intent href="market:*" />
</platform>
<platform name="ios">
    <allow-intent href="itms:*" />
    <allow-intent href="itms-apps:*" />
</platform>
</widget>

I use this plugin: https://github.com/apache/cordova-plugin-whitelist

I added these permissions:

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

I tried searching for the answer in many ways, but I can’t seem to find the solution for this problem. If I need to specify anything, please tell me and I’ll update ASAP.

Greets, Mick


Source: ajax

Leave a Reply