<?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 Problems when trapping 404 (Not Found) error in Software Archive</title>
    <link>https://community.intel.com/t5/Software-Archive/Problems-when-trapping-404-Not-Found-error/m-p/1120610#M75958</link>
    <description>&lt;P&gt;&lt;SPAN style="font-size: 1em;"&gt;Hi&lt;/SPAN&gt;&lt;/P&gt;

&lt;P&gt;I've created a project using Intel XDK (3619) | App Designer | HTML + Cordova template - target iPhone / Android.&lt;/P&gt;

&lt;P&gt;In my app, I want to trap errors when clicking a non-existent link (404) in order to find the missing target name. In a Test project with just two buttons (one which links to a sub-page and one to a non-existent link), The page link works fine; the other, as expected, generates an error message in the simulation console:&lt;/P&gt;

&lt;P&gt;"GET &lt;A href="http://localhost:39875/xxx.html" target="_blank"&gt;http://localhost:39875/xxx.html&lt;/A&gt; 404 (Not Found)"&lt;/P&gt;

&lt;P&gt;I can "trap" the error using .ajaxError which I put inside of the auto generated code:&lt;/P&gt;

&lt;P&gt;/*jshint browser:true */&lt;BR /&gt;
	/*global $ */(function()&lt;BR /&gt;
	{&lt;BR /&gt;
	&amp;nbsp;"use strict";&lt;BR /&gt;
	&amp;nbsp;/*&lt;BR /&gt;
	&amp;nbsp; &amp;nbsp;hook up event handlers&amp;nbsp;&lt;BR /&gt;
	&amp;nbsp;*/&lt;BR /&gt;
	&amp;nbsp;function register_event_handlers()&lt;BR /&gt;
	&amp;nbsp;{&lt;BR /&gt;
	&amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;STRONG&gt;$(document).ajaxError(function(event, jqxhr, settings, thrownError) {&lt;BR /&gt;
	&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; var msg = settings.url;&lt;BR /&gt;
	&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; navigator.notification.alert("Error "+ msg);&lt;BR /&gt;
	&amp;nbsp; &amp;nbsp; &amp;nbsp;});&lt;/STRONG&gt;&lt;BR /&gt;
	&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;BR /&gt;
	&amp;nbsp; &amp;nbsp; &amp;nbsp;/* button &amp;nbsp;Button */&lt;BR /&gt;
	&amp;nbsp; &amp;nbsp; $(document).on("click", ".uib_w_2", function(evt)&lt;BR /&gt;
	&amp;nbsp; &amp;nbsp; {&lt;BR /&gt;
	&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;/*global activate_subpage */&lt;BR /&gt;
	&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;activate_subpage("#uib_page_1");&amp;nbsp;&lt;BR /&gt;
	&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;return false;&lt;BR /&gt;
	&amp;nbsp; &amp;nbsp; }); &amp;nbsp;&amp;nbsp;&lt;BR /&gt;
	&amp;nbsp; &amp;nbsp; }&lt;BR /&gt;
	&amp;nbsp;document.addEventListener("app.Ready", register_event_handlers, false);&lt;BR /&gt;
	})();&lt;/P&gt;

&lt;P&gt;However, when triggered the error event returns "undefined". There is no data in "jqxhr", "settings" or "thrownError". The "event" object has mostly "undefined". Presumably some timing issue???&lt;BR /&gt;
	I've tried many variations, including using .onerror (didn't trigger at all) with no luck. Is there another way to determine the missing target (&lt;SPAN style="font-size: 13.008px;"&gt;xxx.html&lt;/SPAN&gt;)?&lt;BR /&gt;
	Any ideas!&lt;BR /&gt;
	Thanks&lt;BR /&gt;
	Dunum (newbie!)&lt;/P&gt;

&lt;P&gt;ps. apologies if this is not the correct forum - please advise other forums I should try.&lt;/P&gt;</description>
    <pubDate>Thu, 20 Oct 2016 10:10:38 GMT</pubDate>
    <dc:creator>Derek_M_1</dc:creator>
    <dc:date>2016-10-20T10:10:38Z</dc:date>
    <item>
      <title>Problems when trapping 404 (Not Found) error</title>
      <link>https://community.intel.com/t5/Software-Archive/Problems-when-trapping-404-Not-Found-error/m-p/1120610#M75958</link>
      <description>&lt;P&gt;&lt;SPAN style="font-size: 1em;"&gt;Hi&lt;/SPAN&gt;&lt;/P&gt;

&lt;P&gt;I've created a project using Intel XDK (3619) | App Designer | HTML + Cordova template - target iPhone / Android.&lt;/P&gt;

&lt;P&gt;In my app, I want to trap errors when clicking a non-existent link (404) in order to find the missing target name. In a Test project with just two buttons (one which links to a sub-page and one to a non-existent link), The page link works fine; the other, as expected, generates an error message in the simulation console:&lt;/P&gt;

&lt;P&gt;"GET &lt;A href="http://localhost:39875/xxx.html" target="_blank"&gt;http://localhost:39875/xxx.html&lt;/A&gt; 404 (Not Found)"&lt;/P&gt;

&lt;P&gt;I can "trap" the error using .ajaxError which I put inside of the auto generated code:&lt;/P&gt;

&lt;P&gt;/*jshint browser:true */&lt;BR /&gt;
	/*global $ */(function()&lt;BR /&gt;
	{&lt;BR /&gt;
	&amp;nbsp;"use strict";&lt;BR /&gt;
	&amp;nbsp;/*&lt;BR /&gt;
	&amp;nbsp; &amp;nbsp;hook up event handlers&amp;nbsp;&lt;BR /&gt;
	&amp;nbsp;*/&lt;BR /&gt;
	&amp;nbsp;function register_event_handlers()&lt;BR /&gt;
	&amp;nbsp;{&lt;BR /&gt;
	&amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;STRONG&gt;$(document).ajaxError(function(event, jqxhr, settings, thrownError) {&lt;BR /&gt;
	&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; var msg = settings.url;&lt;BR /&gt;
	&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; navigator.notification.alert("Error "+ msg);&lt;BR /&gt;
	&amp;nbsp; &amp;nbsp; &amp;nbsp;});&lt;/STRONG&gt;&lt;BR /&gt;
	&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;BR /&gt;
	&amp;nbsp; &amp;nbsp; &amp;nbsp;/* button &amp;nbsp;Button */&lt;BR /&gt;
	&amp;nbsp; &amp;nbsp; $(document).on("click", ".uib_w_2", function(evt)&lt;BR /&gt;
	&amp;nbsp; &amp;nbsp; {&lt;BR /&gt;
	&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;/*global activate_subpage */&lt;BR /&gt;
	&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;activate_subpage("#uib_page_1");&amp;nbsp;&lt;BR /&gt;
	&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;return false;&lt;BR /&gt;
	&amp;nbsp; &amp;nbsp; }); &amp;nbsp;&amp;nbsp;&lt;BR /&gt;
	&amp;nbsp; &amp;nbsp; }&lt;BR /&gt;
	&amp;nbsp;document.addEventListener("app.Ready", register_event_handlers, false);&lt;BR /&gt;
	})();&lt;/P&gt;

&lt;P&gt;However, when triggered the error event returns "undefined". There is no data in "jqxhr", "settings" or "thrownError". The "event" object has mostly "undefined". Presumably some timing issue???&lt;BR /&gt;
	I've tried many variations, including using .onerror (didn't trigger at all) with no luck. Is there another way to determine the missing target (&lt;SPAN style="font-size: 13.008px;"&gt;xxx.html&lt;/SPAN&gt;)?&lt;BR /&gt;
	Any ideas!&lt;BR /&gt;
	Thanks&lt;BR /&gt;
	Dunum (newbie!)&lt;/P&gt;

&lt;P&gt;ps. apologies if this is not the correct forum - please advise other forums I should try.&lt;/P&gt;</description>
      <pubDate>Thu, 20 Oct 2016 10:10:38 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/Problems-when-trapping-404-Not-Found-error/m-p/1120610#M75958</guid>
      <dc:creator>Derek_M_1</dc:creator>
      <dc:date>2016-10-20T10:10:38Z</dc:date>
    </item>
    <item>
      <title>I'm not clear on how you</title>
      <link>https://community.intel.com/t5/Software-Archive/Problems-when-trapping-404-Not-Found-error/m-p/1120611#M75959</link>
      <description>&lt;P&gt;I'm not clear on how you would detect this. Part of the problem is you're not dealing with access to a traditional web server, there is no web server. All the pages you reference (assuming you are referencing them by name as if they were part of your project) are file:// references, not http:// references.&lt;/P&gt;

&lt;P&gt;In general, building a "multi-page" Cordova app is not recommended. Single-page apps are the recommended procedure. See this Cordova doc page for a little more background &amp;gt; &lt;A href="https://cordova.apache.org/docs/en/latest/guide/next/" target="_blank"&gt;https://cordova.apache.org/docs/en/latest/guide/next/&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 20 Oct 2016 16:54:25 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/Problems-when-trapping-404-Not-Found-error/m-p/1120611#M75959</guid>
      <dc:creator>PaulF_IntelCorp</dc:creator>
      <dc:date>2016-10-20T16:54:25Z</dc:date>
    </item>
    <item>
      <title>Hi Paul, thanks for your</title>
      <link>https://community.intel.com/t5/Software-Archive/Problems-when-trapping-404-Not-Found-error/m-p/1120612#M75960</link>
      <description>&lt;P&gt;Hi Paul, thanks for your response.&lt;/P&gt;

&lt;P&gt;&lt;SPAN style="font-size: 1em;"&gt;My app is actually a single-page app. It is an encyclopaedia type app for iPhone and Android with many content pages (maybe several hundred). I have a simple front end and a content page template (within the single app page) into which I “insert” data (DIVs for “title” and “content”) which I then activate with some simple code. The content is loaded from a SQLite db as text. The issue arose because some content pages may contain links to other content pages. My problem was how to load new content data from a "link" clicked in data already being displayed in the template. The option I was exploring was to embed a non-existent link (e.g. &amp;lt;a href="xxx.html"&amp;gt;xxx&amp;lt;/a&amp;gt;) in the text field, and use .ajaxError to trap the error when it was clicked; then process the re-loading of the template using data determined by the name (url) of the non-existent link. The trap worked but, as I said,&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="font-size: 12px;"&gt;&amp;nbsp;the error event returned "undefined" - so nothing telling me where to link to.&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="font-size: 1em;"&gt;I've now looked at an alternative option which is to embed an onclick function (e.g. &amp;lt;a onclick="showTarget('xxx')"&amp;gt;xxx&amp;lt;/a&amp;gt;) in the text file - &amp;nbsp;'xxx' is passed to the function from which I can determine the page to show.&lt;/SPAN&gt;&lt;/P&gt;

&lt;P&gt;&lt;SPAN style="font-size: 1em;"&gt;I guess there may be alternitive ways of achieving this requirement but t&lt;/SPAN&gt;&lt;SPAN style="font-size: 13.008px;"&gt;his seems to work ok for me:-)&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 23 Oct 2016 11:41:22 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/Problems-when-trapping-404-Not-Found-error/m-p/1120612#M75960</guid>
      <dc:creator>Derek_M_1</dc:creator>
      <dc:date>2016-10-23T11:41:22Z</dc:date>
    </item>
    <item>
      <title>Derek -- thanks for the</title>
      <link>https://community.intel.com/t5/Software-Archive/Problems-when-trapping-404-Not-Found-error/m-p/1120613#M75961</link>
      <description>&lt;P&gt;Derek -- thanks for the clarification. Sounds like you've found a reasonable alternative to the approach you were using.&lt;/P&gt;</description>
      <pubDate>Mon, 24 Oct 2016 17:26:01 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/Problems-when-trapping-404-Not-Found-error/m-p/1120613#M75961</guid>
      <dc:creator>PaulF_IntelCorp</dc:creator>
      <dc:date>2016-10-24T17:26:01Z</dc:date>
    </item>
  </channel>
</rss>

