hi how to pass array while array is,
double[] A={0.8446, 0.8445, 0.8444, 0.8451};
from c# code to Jquery 开发者_开发问答i am trying like this,
<script type="text/javascript">
function Drawgraph( ){
var chart;
alert ("<%= A %>");
series: [{
type: 'area',
name: 'Power to USD',
//pointInterval: 24 * 3600 * 1000,
//pointStart: Date.UTC(2011, 0, 01),
point:Arr,
data: Arr
Hopes for help
Just use the JavaScriptSerializer and write it out into a Javascript variable:
var data = <%new JavaScriptSerializer().Serialize(A)%>
Outputs:
var data = [0.8446,0.8445,0.8444,0.8451];
I would suggest using JSON
for this. Check out the website for more information.
You can use the JavaScriptSerializer
to achieve what you are after.
[WebMethod, ScriptMethod(ResponseFormat = ResponseFormat.Json, UseHttpGet = true)]
public object GetDoubles()
{
return new { 0.8446, 0.8445, 0.8444, 0.8451 };
}
To get this to your client use JQuery AJAX
$.ajax({
url: 'SomeService.asmx/GetDoubles',
type: 'GET',
contentType: 'application/json',
success: function(data){
// access using data (or data.d)
$(data.d).each(function(){
alert(this);
});
}
});
精彩评论