【发布时间】:2011-09-14 11:20:32
【问题描述】:
我编写了下面的例程,为我的 codeigniter 应用程序根据所选国家/地区检索城市。
$(document).ready(function() {
$("select#cbo_country").change(function() {
$.post("http://localhost/main/index.php/city/get_data_by_country", {
int_country_id : $(this).val()
},
function(data) {
// some code here
},'json');
})
});
如您所见,我对 url (http://localhost/main/index.php/city/get_data_by_country) 进行了硬编码,我知道这是一种不好的做法,但我无能为力。
有没有一种不硬编码网址的好方法?我曾经使用codeigniter的base_url(),但是由于我将例程移动到一个js文件,我不再能够使用该函数。
【问题讨论】:
标签: javascript jquery codeigniter