Quantcast
Channel: SCN : Discussion List - SAP HANA Developer Center
Viewing all articles
Browse latest Browse all 6412

$.request.parameters.get to get an Array in XSJS

$
0
0

Hi,

 

I am making an Ajax GET request and sending a json object. I am able to capture the string values in xsjs whereas for the array, it says undefined. How can I get the Array values? Here is how the code looks like:

 

Ajax Call:

 

in the data: results is an array.

 

$.ajax({

       url : getServiceUrl("createUserTags.xsjs"),

       type : "GET",

       data : {"objectId" : objectId , "userId" : oUserId , "tagsArray" : results},

       async : false,

       dataType : "json",

       success : function(data){

            console.log(data);

       }

  });

 

in my xsjs file:

 

var objectId = $.request.parameters.get("objectId");

var tagsArray = $.request.parameters.get("tagsArray"); //---------> I think this is where the issue is

var userId = $.request.parameters.get("userId");

 

var conn = $.db.getConnection();

 

try{

       for (var c = 0; c< tagsArray.length; c++){

               // do something....

     }

    

conn.commit();

 

  $.response.setBody('{"success": "true" }');

  $.response.headers.set("Access-Control-Allow-Origin", "*");

  $.response.contentType = "application/json";

}catch(e){

  $.response.setBody('{"Fail": "' + tagsArray + '"}');

  $.response.headers.set("Access-Control-Allow-Origin", "*");

  $.response.contentType = "application/json";

}

 

 

I get the error message as {"Fail" : "undefined"}, how can I get the tagsArray values?

 

Thank you

Prab


Viewing all articles
Browse latest Browse all 6412

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>