jquery - How to send elements with parsed colors using ajax -


element styles sent browser asp.net mvc4 web api using code below. color properties json data contains strings:

backgroundcolor: "rgba(0, 0, 0, 0)" bordercolor: "rgb(211, 211, 211)" color: "rgb(51, 51, 51)" 

api controller in server should parse strings color values integers.

how send data in parsed form, every rgb component value separate integer property ?

or how parse rgb() strings in mvc api controller rgb values integers ?

or there simpler way send element styles api controller , parse them easly in browser or in mvc controller ?

function designersave() {     var elementstosend = [];     $(".designer-element").each(function () {         var $this = $(this),             moot = $this.css(["width", "height", "text-align", "font-family", "font-size", "font-weight",                 "font-style", "color", "border-color", "background-color"]),             element = {                 id: $this.attr('id'),                 vpos: math.round($this.position().top, 2),                 hpos: math.round($this.position().left, 2),                 width: parsefloat(moot.width),                 height: parsefloat(moot.height),                 textalign: moot["text-align"],                 fontfamily: moot["font-family"],                 fontsize: moot["font-size"],                 fontweight: moot["font-weight"],                 fontstyle: moot["font-style"],                 color: moot.color,                 bordercolor: moot["border-color"],                 backgroundcolor: moot["background-color"]             };         elementstosend.push(element);     });     $.ajax("api/raport",     {         contenttype: "application/json",         data: json.stringify({ elements: elementstosend }),         type: 'post'     }); } 


Comments