Finally worked out a method to get data from the js to c side.