вот мой код:Как добавить переменную php в javascript?
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js"></script>
<?php
$url = "http://api.wunderground.com/api/7d5339867b063fd0/geolookup/conditions/q/UK/".$area.".json";
?>
<script>
jQuery(document).ready(function($) {
$.ajax({
url : ,
dataType : "jsonp",
success : function(parsed_json) {
var location = parsed_json['location']['city'];
var temp_f = parsed_json['current_observation']['temp_f'];
alert("This is an example of a web service outputting using Json. The current temperature in " + location + " is: " + temp_f);
}
});
});
</script>
Как я могу добавить "$ URL" переменной в яваскрипта код на месте "URL: "здесь",
Благодаря
Вы могли бы повторить это? – Parody
Вы пробовали '' '' url: " Php echo $ url;?>" '' ''? –
Возможный дубликат [передачи переменных с php на javascript] (http://stackoverflow.com/questions/7141860/passing-variables-from-php-to-javascript) –