0

I am trying to create a self based opencpu app where user will upload a csv file, will be able to chart csv file:

I have this code:

$(document).ready(function(){
      $("#submitbutton").on("click", function(){

        //arguments
        var myfile = $("#csvfile")[0].files[0];

        if(!myfile){
          alert("No file selected.");
          return;
        }

        //disable the button during upload
        $("#submitbutton").attr("disabled", "disabled");

        //perform the request
        var url;
        var req = ocpu.call("readcsvnew", {
          file : myfile
        }, function(session){
          url=session.getLoc()+"stdout/text";
          //alert(url);
          $.getJSON(url, function(data) {

             console.log(data);
          });

        });

when I uncomment alert(url), I can see the url and it is accurate. Howwever, this following does not seem to be working. What I need to do is assign the output of session.loc()+"stdout/text" into a variable and start manipulating the output. However, console.log(data) is not producing any output. Any ideas?

var req = ocpu.call("readcsvnew", {
              file : myfile
            }, function(session){
              url=session.getLoc()+"stdout/text";
              //below this line is not working. data is empty.
              $.getJSON(url, function(data) {

                 console.log(data);
              });
user1471980
  • 10,127
  • 48
  • 136
  • 235

0 Answers0