开发者

jQuery user input to control option of one jquery function

开发者 https://www.devze.com 2022-12-28 04:31 出处:网络
I\'d like an input to control that : jQuery.ajax({ type: \"get\", dataType: \"jsonp\", url: \"http://www.foo.com/something.php\",

I'd like an input to control that :

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

On the HTML side I've

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

I want when a user enters a number into the j开发者_JS百科queryControl to insert it in the .ajax function and reload the data according to the new value entered.

Any idea to do that please ? Thanks


it's more like .ajax() to get the value. Given that code, it should be:

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

Of course, you should trigger the ajax on somehow, for example on change using the event handler:

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

精彩评论

暂无评论...
验证码 换一张
取 消