Search code examples
node.jsajaxcordovaphonegap

call node.js file from ajax call in phonegap?


I want to call the node.js file through ajax call but unable to did, help me to understand which type of URL will be entered in ajax to call the node.js file.


Solution

  • If you are using Jquery on the client side

    you can make the request this way :

    $.ajax({
    url: 'your-url',
    success: function(data) {
        //it works, do something with the data
    },
    error: function() {
        //something went wrong, handle the error and display a message
    }
    

    });

    You can read more details here PhoneGap and JSON API