PHP Variable to JQuery function?
I need a relative path in this function:
$(function() {
$("#searchbox").autocomplete({
minLength : 2,
source : function (request, response){
开发者_如何学运维 $.ajax({
url : "http://linux/project/index.php/main/search/",
dataType : "json",
data : { key : request.term},
type : "POST",
success : function(data){
response($.map(data, function(item) {
return {
label: item.original_name,
value: item.original_name,
id : item.project_id+"/"+item.folder_id+"/"+item.id
}
}))
}
})
},
select : function(event, ui) {
document.location.href = "http://linux/project/index.php/projects/loaddocument/"+ui.item.id;
}
});
});
How can I use a PHP Variable path to replace http://linux/project in the function above?
Best regards ...
url : "http://<?php echo $path; ?>/index.php/main/search/"
Or, if the script is in a separate .js file, something like this:
// in the main page
<script type="text/javascript" charset="utf-8">
var config = { basePath : '<?php echo $path; ?>' };
</script>
// in the .js file
url : "http://" + config.basePath + "/index.php/main/search/"
is there an efficient way to serialize the translation of the dayNamesMin and monthNames, or did I have to do this for each item?:
$(function() {
$("#datepicker").datepicker({
dateFormat : 'dd.mm.yy',
showWeek : true,
firstDay : 1,
weekHeader : 'KW',
dayNamesMin : ['So','Mo','Di','Mi','Do','Fr','Sa'],
monthNames : ['Januar','Februar','März','April',
'Mai','Juni','Juli','August','September',
'Oktober','November','Dezember'],
onSelect : function(dateText,inst){
}
});
});
精彩评论