Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/72.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
jQuery post返回变量_Jquery_Post - Fatal编程技术网

jQuery post返回变量

jQuery post返回变量,jquery,post,Jquery,Post,我需要根据来自jQuery帖子的Javascript变量设置表的宽度 $.post("get.php", {this: 'that'}, function(data){ var width = data // eg '300' ? set table width to 'width' 对于jQuery,我是新手,我知道如何将return设置为div标记,但我猜这对我来说没有帮助。首先使用parseInt转换为数值,然后只设置jQuery对象的width属性: var width = par

我需要根据来自jQuery帖子的Javascript变量设置表的宽度

$.post("get.php", {this: 'that'}, function(data){ 
var width = data // eg '300'

? set table width to 'width'

对于jQuery,我是新手,我知道如何将return设置为div标记,但我猜这对我来说没有帮助。

首先使用
parseInt
转换为数值,然后只设置jQuery对象的
width
属性:

var width = parseInt(data, 10);
$("#myTable").width(width);

“myTable”应该更改为实际
元素的ID。

正如影子向导所说,这里是jquery文档页面