2010-04-27 20 views
0

我想输入来控制:jQuery的用户输入来控制一个jQuery的功能选项

jQuery.ajax({ 
    type: "get", 
    dataType: "jsonp", 
    url: "http://www.foo.com/something.php", 
    data: {numberInput: "NUMBER I WANT TO CONTROL" }, 

在HTML方面我已经

<input type="text" id="jqueryControl" /> 

当用户输入我想将数字插入jqueryControl以将其插入.ajax函数并根据输入的新值重新载入数据。

有什么想法可以这么做吗? 谢谢

回答

2

它更像是.ajax()来获得价值。由于代码,它应该是:

jQuery.ajax({ 
    type: "get", 
    dataType: "jsonp", 
    url: "http://www.foo.com/something.php", 
    data: { numberInput: $('#jqueryControl').val() }, 
    ...}); 

当然,你应该用事件处理程序触发Ajax上不知何故,例如在变化:

$('#jqueryControl').change(function(){ $.ajax({ ... }); }); 
+0

完善;)谢谢 – 2010-04-27 23:11:04

相关问题