erol_smsr
erol_smsr

Reputation: 1496

Intel XDK getRemoteData Method and PHP

I'm working on an app with Intel XDK (love it so far) and I want to use PHP/MySQL for the back end. My problem is that AJAX calls won't work because cross domain AJAX calls are blocked. As an alternative I can use the getRemoteData Method included in Intel XDK, however, can I also use this for PHP scripts?

I'm asking this because with a regular website and JQuery AJAX, I do something like this:

$("#sign_up_form").submit( function() {
    $.post( $("#sign_up_form").attr("action"),
    $("#sign_up_form :input").serializeArray(),
    function(info) {
        if(info != "You've signed up! Please confirm your email address to use Scrapll.") {
            $("#warning").html(info).fadeIn(200).delay(3000).fadeOut(200);
        }
        else {
            $("#cover").fadeIn(200);
            $("#sign_up_field").fadeOut(200);
            $("#account_control").fadeOut(200);
            $("#success").html(info).fadeIn(200);
        }
    });
    return false;
});

This is a snippet from a previous project. What should I do to use something similar to this in my app and fix this cross domain issue with AJAX calls? Do I have to use JSON for his? Because I was planning to just output HTML, not JSON or anything.

Upvotes: 1

Views: 2680

Answers (1)

xmnboy
xmnboy

Reputation: 2310

Cross domain calls will work, but you have to enable that. If you are using the "legacy" builds you enable that by including a reference to xhr.js in your index.html file, after the intelxdk.js reference. If you are building for Cordova (the default for the 1199 version of XDK) you set that by specifying a specific domain or using * in the "Domain Access" field in the "Build Settings" section of the Projects tab.

See this article, written by one of my colleagues, for additional information: https://software.intel.com/en-us/html5/articles/how-to-access-JSON-data-in-HTML5-apps

Upvotes: 1

Related Questions