只是想知道我如何将值从“var vname”保存到“$data”,以便我可以在我的 php.ini 中使用该值。假设这很容易,但我是新手:P
<script id="source" language="javascript" type="text/javascript">
//Call the yourAjaxCall() function every 1000 millisecond
setInterval("yourAjaxCall()",1000);
function yourAjaxCall()
{
//-----------------------------------------------------------------------
// 2) Send a http request with AJAX http://api.jquery.com/jQuery.ajax/
//-----------------------------------------------------------------------
$.ajax({
url: 'api.php', //the script to call to get data
data: "", //you can insert url argumnets here to pass to api.php
//for example "id=5&parent=6"
dataType: 'json', //data format
success: function(data) //on recieve of reply
{
var id = data[0]; //get id
var vname = data[1]; //get name
$data = vname; //HOW AND WHERE??????? :P
}
});
};
</script>
/EDIT - want my var vname which is a color, to be placed in the style.
<body>
<div id="kvadrat1" style="width:200px; height:200px; position:relative; background-color:'HERE I WANT MY VALUE'">
</div>
非常适合快速回答!:)