locked
HTML Web Resource in form with OData/REST call RRS feed

  • Question

  • Hi,

    I am trying to retrieve CRM 2011 data using oDate/REST

    My code works fine if I add it to the form_Load event as a javscript file

    but when I place the same code as HTML resource file, it is not displaying any value after this 'JSON.parse(req.responseText).d'

     if (req.readyState === 4) {  --> fine
                            if (req.status === 200) {  --> fine
                                var retrieved = JSON.parse(req.responseText).d;

    alert(retrieved); won't fire

    i have added js file as well

        <script src="ClientGlobalContext.js.aspx"></script>

     <script type="text/javascript" src="new_jquery1.4.1.min.js"></script>

     <script type="text/javascript" src="new_json2.js"></script>


    Any help is appreciated 

    Thanks


    Friday, November 22, 2013 8:20 AM

Answers

  • Hi,

    Can you verify the path of the JS files being referred. Adding a "../" before the js files solves the purpose. Moreover check the exact name of the js file if it contains ".js" in the name as well. The Sample code is given below:

        <script type="text/javascript" src="../ClientGlobalContext.js.aspx"></script>
        <script type="text/javascript" src="../Scripts/SDK.REST.js"></script>
        <script type="text/javascript" src="../Scripts/json2.js"></script>
        <script type="text/javascript" src="../Scripts/jquery.js"></script>

    The above sample code will give an idea of how to use the correct path for the js files, if you giving the names as "/Scripts/json2.js".

    Moreover, You may also verify "this.parent.JSON.parse" which also sometimes works depending on the scenarios of html web resources present in the forms.

    I hope this will help you to proceed with the resoution.

    Let me know in case you find any difficulty.

    Thanks & Regards,


    Anubhav Bajpai


    • Edited by Anubhav Bajpai Friday, November 22, 2013 8:36 AM Updated this.parent.JSON.parse
    • Marked as answer by Shwetha Keremane Sunday, November 24, 2013 10:57 PM
    Friday, November 22, 2013 8:33 AM

All replies

  • Hi,

    Can you verify the path of the JS files being referred. Adding a "../" before the js files solves the purpose. Moreover check the exact name of the js file if it contains ".js" in the name as well. The Sample code is given below:

        <script type="text/javascript" src="../ClientGlobalContext.js.aspx"></script>
        <script type="text/javascript" src="../Scripts/SDK.REST.js"></script>
        <script type="text/javascript" src="../Scripts/json2.js"></script>
        <script type="text/javascript" src="../Scripts/jquery.js"></script>

    The above sample code will give an idea of how to use the correct path for the js files, if you giving the names as "/Scripts/json2.js".

    Moreover, You may also verify "this.parent.JSON.parse" which also sometimes works depending on the scenarios of html web resources present in the forms.

    I hope this will help you to proceed with the resoution.

    Let me know in case you find any difficulty.

    Thanks & Regards,


    Anubhav Bajpai


    • Edited by Anubhav Bajpai Friday, November 22, 2013 8:36 AM Updated this.parent.JSON.parse
    • Marked as answer by Shwetha Keremane Sunday, November 24, 2013 10:57 PM
    Friday, November 22, 2013 8:33 AM
  • Hi Anubhav,

      Thanks for helping to resolve the issue.

    Replacing "this.JSON.parse" with "this.parent.JSON.parse" solved it

    Thanks

    Sunday, November 24, 2013 10:57 PM