Search code examples
ibm-mobilefirstworklight-serverworklight-studio

Worklight preview shows Network Error - 404


I am getting the following error in firebug when I preview my app from Worklight console. Also the image is missing in preview.

"NetworkError: 404 Not Found - http://192.168.3.100:10080/WorklightSample/apps/services/preview/MyApp/common/0/images/logo.png"

All the files are present in the corresponnding folders in the project. From the tips got from Stackoverflow and other forums, I tried the following:

  1. Cleared wlBuildResources
  2. Cleaned Worklight Development Server
  3. Cleared bin folder
  4. Deleted Worklight Development Server and restarted eclipse
  5. Changed workspace

All these of no use. How can I remove this error?

Edit: My index.html is:

<body style="display:none;">
        <div data-role="page" id="loginPageDiv">
            <div data-role="content" style="padding: 15px">

            </div>
        </div>
        <div data-role="page" id="forgotPasswordPageDiv">
            <div data-role="content" style="padding: 15px"></div>
        </div>
<script src="js/initOptions.js"></script>
        <script src="js/main.js"></script>
        <script src="js/messages.js"></script>
        <script type="text/javascript">
        $(document).ready(function(){
            $("#loginPageDiv").load("pages/loginPage.html");
        });
        </script>
    </body>

and my loginPage.html in pages folder is

<div id="wrapper">
<img src="../images/logo.png" /> <br>
<div id="searchText">Please enter your username and password</div>
<input id="emailBox" class="loginInput" type="text" placeholder="Email Address">
<input id="passwordBox"  class="loginInput" type="text" placeholder="Password"><br> 
<div id="checkboxDiv"><input type="checkbox" checked="checked">Keep me signed in</div> <br>
<input type="submit" class="btn-common-green" name="searchBtn" value="Search" onclick="getSearchResults();">
</div>    

When i add the code as

<img src="images/logo.png" />

in index.html, the image is being loaded in index page. Why it is not taking the image when code is given in inner page?


Solution

    1. I do not believe you need the follow code snippet where you've placed it. Rather, you need to call that page in main.js > wlCommonInit().

    2. For the img tag, it should work without the ..: <img src="images/logo.png" />