Opening a file using JQuery(to fetch the data from the file)

My application has 2 dropdowns, when i select the value in the first dropdown, i need to get the data from the xml file and bind it to the second dropdown in my form. i have tried with JQuery AJAX functionality, but it is not wokring. Can you guys suggest me any other way around with JQuery.

Comments

  • In what context ? How is the JQuery called ? From a DCR ? From the external website ? From a TS custom menu item?
  • We have two dropdowns, Lets say i have selected Orange form the first dropdown,i have to read the Orange.xml file that is in the same working folder and get the values from it and bind it to the 2nd dropdown, to open the Orange.xml file and fetch the value from it, i have used an AJAX call along with the javascript, but the AJAX call is not working. I uploaded the jquery-1.4.2.min.js into the folder in which i am working on.
  • but the AJAX call is not working.
    Maybe you should explain why it is not working.
  • How your are populating your first drop down?

    Why don't you use callserver instead of JQuery+AJAX?
  • We have implemented some of the applications with callserve+perl.
    But we an issue with perl files so we are trying to find alternative, we want to reduce the use of perl as much as we can. So i am trying to implement JQuery.
    The following is the AJAX call i have used in the JS file for the implementation.
    $.ajax({
    type: "GET"
    url: "Orange.xml"
    dataType: "xml"
    success: function(xml){
    $(xml).find('Orange').each(function(){
    var orange = $(this).text();
    alert(orange);
    });
    }
    });

    i think the problem is with the URL, i have tried giving the total URL from http, it is not working that way. Can anyone suggest on this?
  • If your facing issue with CallServerver+perl..then why dont you try with CallServer+jsp?
  • There are various ways to achieve what you're after, but it all depends on the context.

    In none of the three threads that you've started on this subject have you said where the dropdowns are. Is this on a data capture form, in a LS component, on a HTML page, or somewhere else?

    As you're trying to use jQuery, I would assume that this isn't in TeamSite per se, but on a page you're creating in TeamSite. This makes it more of a web development question than a TeamSite question which would possibly be better asked on a web development forum, such as sitepoint.
    3.PNG 103.3K
    4.PNG 38.3K
  • I got ur point. The dropdowns are in the datacapture form. Yes i need to develop a Webpage.
  • OK, so this is in your data capture template. In that case the tool for the job is callserver. Using jQuery will be at best difficult and at worst will shave a good few years off your life. You don't have to use Perl on the server side, but if you haven't got another server-side language set up on the server it will be your only choice.
  • I do things like this all the time with call servers and perl

    The most common mistake is that the call server is asynchronous and will complete when it is done and return no data.

    So you need to have a function that it invoked by the call server in the original JS which will create the menus.

    The other thing that happens is, unless you plan things correctly, there is no debug information from your call server. You need a timeout defined and logging to see that it is doing what you expect it to do
  • Rasjmika,

    your question is VERY vague. Jquery is NOT a replacement for perl but for callserver. My advise to you would be:

    1. first test your cgi (be it perl, java, hocus-pocus) with a url in a browser. If this works:

    2. make yourself well known to jquery (or stick to callserver)

    3. call your url in jquery (or callserver)

    If it still fails, ask this forum for advise, but ONLY with a well defined question, including any error-messages you might have found.
  • Hi
    I have to Create a DCT with two drop downs. In the first drop down has 2 values(eg. Orange and Red). Corresponding xml's, Orange.xml and Red.xml are Saved in the same folder. Now, when I select Orange from first drop down, the second drop down should show values present in Orange.xml in its list. Same goes for Red.
    Sample Orange.xml:

    Orange1
    Orange2
    Orange3

    I have tried to retrieve the values from the xml(eg. Orange.xml) using a AJAX call. The following is the AJAX call i made



    $.ajax({
    type: "GET"
    url: "http://pg-devts- 01/default/main/haircare/SessionSamples/Master/WORKAREA/workinprogress/Configuration/Orange.xml"
    dataType: "xml"
    success: function(xml){
    $(xml).find('Value').each(function(){
    var orange = $(this).val();
    alert(orange);
    });
    }
    error: function(xml){
    alert("Error");
    }
    });



    But this call is not working, alerts are not displayed too. I think there is a problem with the URL, AJAX call is not able to access the Orange.xml file.
    If there's a way to get the error message relayed back, please do let me know how can this be captured in Teamsite?
  • I'd recommend using Firefox with Firebug to try to debug the issue - if you're not getting alerts, it's usually a syntax error, or unresolved object reference, that stops the javascript code dead in its tracks.
  • I believe that his last issue was the fact that the xml, http://pg-devts- 01/default/main/haircare/SessionSamples/Master/WORKAREA/workinprogress/Configuration/Orange.xml, could not be returned.

    I have been able to use ajax for xml retrieval using the no-injection URL that is normally for viewing static content.

    If he formatted his URL like this it should work:
    http://pg-devts- 01/iw/cci/meta/no-injection/iw-mount/default/main/haircare/SessionSamples/Master/WORKAREA/workinprogress/Configuration/Orange.xml.

    This method eliminates the need for any extra coding to use callserve.
TeamSite Developer Resources

  • Docker Automation

  • LiveSite Content Services (LSCS) REST API

  • Single Page Application (SPA) Modules

  • TeamSite Add-ons

If you are interested in gaining full access to the content, you can register for a My Support account here.
image
OpenText CE Products
TeamSite
APIs