I Currently have events set in my datepicker based of my filter.js file that uses something like:
var events = [
{ Title: "1", Date: new Date("12/4/2010") },
{ Title: "2", Date: new Date("1开发者_开发问答2/10/2010") }
];
I have these dates stored in a mysql db and I need to pull the dates from it instead of a static js file. Dates can be added, changed, etc.
I'm using vb .net
Suggest creating a web service that serves your latest events/dates. Then your JavaScript code can call into that web service.
Imports System.Web
Imports System.Web.Services
Imports System.Web.Services.Protocols
<WebMethod> _
<ScriptMethod(ResponseFormat := ResponseFormat.Json)> _
Public Shared Function GetDates() As String
'return a collection as you need
End Function
On the JS side, call this web service using jQuery:
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
$.ajax({
type: "POST",
url: "YourWebServiceURL.aspx/GetDates",
data: "{}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function(msg) {
var events ; //get your events from the msg object.
}
});
精彩评论