我有一个插件,它包含一个插入/从数据库中获取数据的函数。 我的问题是我如何使用jquery或链接在wordpress插件中的任何其他JS。 我搜索并找到很多文章,但它不清楚,请我nead步骤添加jquery文件在我的插件。 我试过的贝尔台阶 在我的页面顶部添加此行。在wordpress插件中使用jquery
其是我的插件代码
和下面是位于C fn.js:\瓦帕\万维网\测试\可湿性粉剂内容\插件\为myplugin \ fn.js
<script type="text/javascript">
$(document).ready(function(){
<!-- ajax method to bind the dropdown menu of model-->
$("#select_brand").change(function(){
var id=$(this).val();
var dataString = 'id='+ id;
$.ajax({
type: "POST",
url: "model.php",
data: dataString,
cache: false,
success: function(data)
{
$("#select_Model").html(data);
}
});
});
<!-- ajax method to bind the dropdown menu of city-->
$("#select_Country").change(function(){
var id=$(this).val();
var dataString = 'id='+ id;
$.ajax({
type: "POST",
url: "city.php",
data: dataString,
cache: false,
success: function(data)
{
alert("yes");
$("#select_city").html(data);
}
});
});
});
</script>
和city.php
<?php
if($_POST['id'])
{
global $wpdb;
$id=$_POST['id'];
$query="select id,CountryCode,City from _city where CountryCode='$id'";
$result=$wpdb->get_results($query);
echo '<option selected="selected" disabled="disabled"> -- Select City -- </option>';
foreach ($result as $row)
{
$id=$row->id;
$city=$row->city;
echo '<option value="'.$id.'">'.$city.'</option>';
}
}
?>
问题的最终代码城市下拉不能得到的值。
这听起来像正在排队的jQuery就好了。你在哪里看到错误? – rnevius 2014-12-09 12:38:40
当我在控制台浏览器中按Ctrl + Shift + J。 和代码不工作 – Bassem 2014-12-09 12:40:31
@webeno,我已经阅读但有些不明确 – Bassem 2014-12-09 12:41:44