-1

I'm getting control text as an array and I want to pass this to $.post as string. I need suggestions on how to convert it to string.

var controlText = $("input[name='control_text']").map(function() {
    return this.value;
}).get();
//alert(controlText);      
$.post("dbfile.php", {
    columns_one: columns_one,
    controlText: controlText,
    controlPara: controlPara,
    mandatoryValue: mandatoryValue
},
4

1 回答 1

1

你可以用逗号加入他们:

var controlText = $("input[name='control_text']").map(function() {
    return this.value;
}).get().join( "," );

或 json 编码:

var controlText = JSON.stringify( $("input[name='control_text']").map(function() {
    return this.value;
}).get() );
于 2012-11-03T20:14:37.987 回答