0
我收到了一些函数的问题,其中我传递了2个参数,其中一个包含字符串“12345.00”,主要问题是在console.log(字符串)这个回报只有“12345”。通过javascript函数将字符串传递给ajax
有没有办法得到整个字符串?
$data = array(
array(
'arg1' => '1',
'arg2' => '123'
),
array(
'arg1' => '2',
'arg2' => '12345.00'
)
);
<button id="openTab">Test</button>
foreach($data as $item){
<script>
$('#openTab').click(function(e){
e.preventDefault();
getValues(<?php echo $item['arg1'](); ?>, <?php echo $item['arg2']; ?>);
});
</script>
}
function getValues(arg1, arg2){
console.log(arg2);
new Ajax.Request("<?php echo $this->getUrl('getValues') ?>", {
method: 'POST',
type: 'json',
parameters: { arg1: arg1, arg2: arg2},
onComplete: function(transport) {
var result = JSON.parse(transport.responseText);
console.log(result);
}
});
}
您使用的是什么浏览器?您提供的代码在Chrome中返回字符串“12345.00”。 –
欢迎来到JS型强制。但你确定吗?我无法重现这一点:'getValues('1','12345.00'); > 12345.00'你是否以任何其他方式操纵价值? –
确定,它为我在Chrome –