<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic the solution was to use JSONP in Software Archive</title>
    <link>https://community.intel.com/t5/Software-Archive/Ajax-error/m-p/1076100#M59929</link>
    <description>&lt;P&gt;the solution was to use JSONP, not JSON for my CGI request&lt;/P&gt;</description>
    <pubDate>Mon, 23 Jan 2017 17:22:19 GMT</pubDate>
    <dc:creator>Shawn_A_</dc:creator>
    <dc:date>2017-01-23T17:22:19Z</dc:date>
    <item>
      <title>Ajax error</title>
      <link>https://community.intel.com/t5/Software-Archive/Ajax-error/m-p/1076099#M59928</link>
      <description>&lt;P&gt;My code works fine in the simulator, but when I push to the test app on my phone, I get an error when I do an AJAX call to me server.&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;PRE class="brush:jscript;"&gt;// login and receive token and a list of tickets
function login(){
    
    var userID=$("#userID").val();
    var userPW=$("#userPW").val();
    if( !userID || !userPW){
        alertify.alert("Please enter user and password");
        return;
    }
    
    var dataString="userID="+escape(userID)+"&amp;amp;userPW="+escape(userPW);
    
    spinner(1);   // turn on "waiting" animation 

     $.ajax({    
            url: "http://myDomain.com/cgi/mlogin.exe",    
            dataType: "json",		
            data: dataString,
            error: ajaxError, 	
            success: function(json){   	 	

                if(json.error !== "0"){
                    spinner(0);
                    alertify.alert("ERROR "+json.error);
                    return;
                }	

                setToken(json.token);
                
                $("#actionDiv").load("stubs/logonReturn.html");

                setTimeout(function(){
                    var tlist=$("#ticketList");
                    var ticket="";
                    var custID="";                    

                    for(var i=0;i&amp;lt;=json.tickets.length-1;i++){
                            ticket=json.tickets&lt;I&gt;.ticket;
                            custID=json.tickets&lt;I&gt;.custID;
                            tlist.append( $("&amp;lt;option class='tlOption'&amp;gt;&amp;lt;/option&amp;gt;").attr("value", ticket ).text( ticket+" "+custID ) ); 
                    }

                    spinner(0);   
                },1000);   
               
            }
     });
    
}
&lt;/I&gt;&lt;/I&gt;&lt;/PRE&gt;

&lt;PRE class="brush:jscript;"&gt;         
// generic ajax error handler
function ajaxError(request, type, errorThrown) {
    var message = "There was an error with the AJAX request.\n";
    switch (type) {
    case 'timeout':
        message += "The request timed out.";
        break;
    case 'notmodified':
        message += "The request was not modified but was not retrieved from the cache.";
        break;
    case 'parsererror':
        message += "XML/Json format is bad.";
        break;
    default:
        try{
        	message += "HTTP Error (" + request.status + " " + request.statusText + ").";
        }catch(e){
        	return;
        }	
    }
    message += "&amp;lt;br&amp;gt;";
    alertify.alert(message);
    spinner(0);
}&lt;/PRE&gt;

&lt;P&gt;The error is 0; eg, no error.&lt;/P&gt;

&lt;P&gt;&lt;SPAN style="font-size: 1em;"&gt;why?&lt;/SPAN&gt;&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 20 Jan 2017 21:41:09 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/Ajax-error/m-p/1076099#M59928</guid>
      <dc:creator>Shawn_A_</dc:creator>
      <dc:date>2017-01-20T21:41:09Z</dc:date>
    </item>
    <item>
      <title>the solution was to use JSONP</title>
      <link>https://community.intel.com/t5/Software-Archive/Ajax-error/m-p/1076100#M59929</link>
      <description>&lt;P&gt;the solution was to use JSONP, not JSON for my CGI request&lt;/P&gt;</description>
      <pubDate>Mon, 23 Jan 2017 17:22:19 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/Ajax-error/m-p/1076100#M59929</guid>
      <dc:creator>Shawn_A_</dc:creator>
      <dc:date>2017-01-23T17:22:19Z</dc:date>
    </item>
  </channel>
</rss>

