简体   繁体   English

每当单击表单元素时,如何进行PHP调用?

[英]How do I make a PHP call whenever a form element is clicked?

I have a jQuery colorbox opened over top of my webpage (with a <select> drop down list) and I'd like to make an AJAX call every time a new <option> is selected from the drop down. 我在网页上方打开了一个jQuery颜色框(带有<select>下拉列表),并且每次从下拉列表中选择新的<option>时,我都希望进行AJAX调用。

I have the following code, but it's not picking up the select event. 我有以下代码,但它没有处理select事件。

$('#cboxLoadedContent select[name=parent]').live('select', function() {
  $.get("edit.php", { fn: 'getFormatLevel', parent: $('select[name=parent]').val() }, function(data) {
    alert("Data Loaded: " + data);
  });
});

Any ideas why this isn't even recognizing my selector? 为什么这甚至不能识别我的选择器的任何想法?

Does a select event exist? 是否存在select事件? I think it has to be change : 我认为必须change

$('#cboxLoadedContent select[name=parent]').live('change', function() {
   $.get("edit.php", { fn: 'getFormatLevel', parent: $(this).val() }, function(data) {
        alert("Data Loaded: " + data);
   });
});

我不确定“选择”是否是您可能想尝试“更改”或“单击”的事件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM