Jquery/Zepto $.post does not seem to work...

Thread is closed for posting
8 posts, 0 answers
  1. Ryan
    Ryan avatar
    4 posts
    Member since:
    Jun 2012

    Posted 19 Jun 2012 Link to this post

    Hey Guys, 
        I'm still trying to get my app to work in Mist (I don't have a Windows machine unfortunately so I think this is my only option), but it seems that $.post calls through jQuery or Zepto fail. I assume it's because the files are not hosted on my server and the aren't running in local mode as compiled apps do so there are security issues. What is the solution for this? Without being able to test my app with $.post calls to my api, it's useless. Am I missing something? I'd love to figure out how to make this work. Conceptually it's a great idea. Thanks


  2. Jordan
    Jordan avatar
    3 posts
    Member since:
    Jun 2012

    Posted 19 Jun 2012 Link to this post

    Due to browser security restrictions, most "Ajax"
    requests are subject to the same origin policy and the request cannot
    successfully retrieve data from a different domain, sub-domain, or protocol.

    Unfortunately only Graphite (windows client) simulator is applicable for
    debugging such scenarios.

    But you may workaround this browser limitation by:

    1. Test on device as you need to build and install the application only once,
    then use [menu] key on Android device or hold down three fingers for 1 sec on
    iOS device to sync.

    2. Or use CORS and alter security with custom header while testing with Mist simulator
    make your server return this custom header:
       Access-Control-Allow-Origin: http://app.icenium.com

    3. Or by using JSONP services
    Here is an example of JSONP, Twitter search (http://pastebin.com/mD5shPKE) just
    paste at index.html in Icenium  new jQuery project.

    Please let me know if I can be of any further help,
  3. Andy
    Andy avatar
    1 posts
    Member since:
    Jul 2012

    Posted 25 Jul 2012 Link to this post

    I'm not sure if this will work for you, but I have done this in the past to work around same origin policy problems. When you launch Chrome you can disable security, so the browser won't enforce any of the same origin policy restrictions.

    Mac terminal:
    open -a Google\ Chrome --args --disable-web-security
  4. David
    David avatar
    1 posts
    Member since:
    Apr 2013

    Posted 05 Jun 2013 Link to this post

    Will this work with Icenium Ion?
  5. Steve
    Steve avatar
    10941 posts

    Posted 05 Jun 2013 Link to this post

    Hi David,

    ION is just a container for your app, so it would work the same way as your app would work when deployed directly on the device.


    Looking for tips & tricks directly from the Icenium team? Check out our blog!
    Share feedback and vote for features on our Feedback Portal.
  6. Abdul
    Abdul avatar
    7 posts
    Member since:
    May 2013

    Posted 20 Jun 2013 Link to this post

    Hi Steve,
                     How r u...
    while connecting REST i am getting error....
    Origin http://app.icenium.com is not allowed by Access-Control-Allow-Origin.

    Code :

    function getContactList(){
            console.log("Entering getContactList()");
                type: "GET",
                url : "http://localhost:8080/rest/3.2/contactinfo/contactrest",
                dataType: "xml",
                 cache: true,
              error:function (xhr, ajaxOptions, thrownError){
              success : function(xml) {
                console.log("Entering getContactList.success()");
                  var html = '<li>' + $(this).find("fname").text()
                  + ' ' + $(this).find("lname").text() +'</li>';
                console.log("Exiting getContactList.success()");
            console.log("Exiting getContactList()");

    thanks and regards

  7. Chris Gillies
    Chris Gillies avatar
    384 posts
    Member since:
    May 2006

    Posted 20 Jun 2013 Link to this post

    XMLHttpRequest will not let you reach localhost because of the "same origin policy".This error has been discussed times and times again, just search for "is not allowed by Access-Control-Allow-Origin", here are a few posts with nice explanations:
    • http://www.cypressnorth.com/blog/programming/cross-domain-ajax-request-with-json-response-for-iefirefoxchrome-safari-jquery/
    • http://stackoverflow.com/questions/10143093/origin-is-not-allowed-by-access-control-allow-origin
  8. Iva Koevska
    Iva Koevska avatar
    286 posts

    Posted 17 Apr 2014 Link to this post

    Hi all,

    If you're using the in-browser client in Chrome, you can get the Telerik AppBuilder Helper for Chrome which enables Ajax CORS requests for the device simulator to spare you the CORS errors.

    You can get it from here. The team plans to bring more improvements in the Helper in the future, so keep an eye on it.

    Iva Koevska

    Share what you think about AppBuilder and Telerik Platform with us in our feedback portal, so we can become even better!

Back to Top