MSDN Community Support
Please remember to click "Mark as Answer" the responses that resolved your issue.
If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.
You set a break point at the place where data hasn't been defined and the date is in a function which is hard to check, please set a break point at 1425 line to see the data.
And you could see my code is start not date , it matters because full calendar doesn't recognize date ,.
data = data.d.map(function (e) {
return {title:e["training_title"],start:e.date}
})
Below is my break point.
Best regards,
Ackerly Xu
MSDN Community Support
Please remember to click "Mark as Answer" the responses that resolved your issue.
If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.
You set a break point at the place where data hasn't been defined and the date is in a function which is hard to check, please set a break point at 1425 line to see the data.
If I put debugger on top then break point doesn't come inside map function, instead it goes to the close tag of script means </script>.
Then I place debugger here and see the result below.
Thanks
It is our choices, that show what we truly are, far more than our abilities.
data = data.d.map(function (e) {
return {title:e["training_title"],start:e.date}
})
As you could see , e is the parameter of the function that you have passed to map method, so if you remove the function , it will show the error.
If you want to debug the map method , please don't directly return the result, please write as follows.
data = data.d.map(function (e) {
var obj = {title:e["training_title"],start:e.date}
return obj;
})
Best regards,
Ackerly Xu
MSDN Community Support
Please remember to click "Mark as Answer" the responses that resolved your issue.
If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.
If you don't want to use map method, you could refer to the code below, manually loop through the array and set data.
$(function () {
$.ajax({
type: "POST",
url: "/Services/MyService.asmx/HelloWorld",
data: JSON.stringify({ user_id: 1006 }),
contentType: "application/json",
datatype: "json",
success: function (data) {
//define an array to store the final data
var target = [];
// loop through data.d array
for (var i = 0; i < data.d.length; i++) {
//get training_title and set to an object's title property ,get date and set the object's start property to date.
var item = { title: data.d[i]["training_title"], start: data.d[i]["date"] }
// add the item to the target array
target.push(item);
}
$('#calendar').fullCalendar({
editable: false,
events: target // use the target array as events' datasrouce
})
},
error: function (XMLHttpRequest, textStatus, errorThrown) {
}
});
})
Best regards,
Ackerly Xu
MSDN Community Support
Please remember to click "Mark as Answer" the responses that resolved your issue.
If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.
$('#calendar').fullCalendar({
editable: false,
events: target // use the target array as events' datasrouce
})
Best regards,
Ackerly Xu
MSDN Community Support
Please remember to click "Mark as Answer" the responses that resolved your issue.
If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.
After this my calendar changes like this And event is on 26th march which is not coming in calendar. Sorry, but I am very new to jquery, that's why I am facing this.
It is our choices, that show what we truly are, far more than our abilities.
And it seems that you should set startDate and endDate, if you are using bootstarp calendar
I have found little resource about the plugin , could your share your link that withe bootstarp calendar?
$.ajax({
type: "POST",
url: "/Services/MyService.asmx/HelloWorld",
data: JSON.stringify({ user_id: 1006 }),
contentType: "application/json",
datatype: "json",
success: function (data) {
var target = [];
// loop through data.d array
for (var i = 0; i < data.d.length; i++) {
//get training_title and set to an object's title property ,get date and set the object's start property to date.
var item = { name: data.d[i]["training_title"], startDate: Date.now(),endDate: new Date(2019, 4, 29) }
// add the item to the target array
target.push(item);
}
$('#calendar').calendar({
enableContextMenu: true,
enableRangeSelection: true,
dataSource: target // use the target array as events' datasrouce
})
},
error: function (XMLHttpRequest, textStatus, errorThrown) {
}
});
You say you have not seen event on 26th using full calendar , could you debug your code and see that data.d is?As you could see , other date shows well.
Best regards,
Ackerly Xu
MSDN Community Support
Please remember to click "Mark as Answer" the responses that resolved your issue.
If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.
undefined means you haven't get the value, how do you get the name?
I write
var target = [];
// loop through data.d array
for (var i = 0; i < data.d.length; i++) {
//get training_title and set to an object's title property ,get date and set the object's start property to date.
var item = { name: data.d[i]["training_title"], startDate: Date.now(),endDate: new Date(2019, 4, 29) }
// add the item to the target array
target.push(item);
}
I need to know what you data looks like.
Best regards,
Ackerly Xu
MSDN Community Support
Please remember to click "Mark as Answer" the responses that resolved your issue.
If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.
It's strange , there is only one item , the array should not contain so many elements.
Could you show me all your js code?
Best regards,
Ackerly Xu
MSDN Community Support
Please remember to click "Mark as Answer" the responses that resolved your issue.
If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.
success: function (data) {
alert(data.d.date); // gives you 2/24/2019 12:00:00 AM
//... },
Now you can simply bind this date to your calendar.
Helping you always. Don't forget to click "Mark as Answer" on the post that helped you.
♠ ASP.NET Core Tutorials → Start from the Beginning and become an Expert in 30 days time ♠
I think you could debug your code to check your array of data after the ajax call returns.
I wonder it is not an empty array.
$.ajax({
type: "POST",
url: "/Services/MyService.asmx/HelloWorld",
data: JSON.stringify({ user_id: 1006 }),
contentType: "application/json",
datatype: "json",
success: function (data) {
// here debug to see your array
var target = [];
// loop through data.d array
for (var i = 0; i < data.d.length; i++) {
//get training_title and set to an object's title property ,get date and set the object's start property to date.
var item = { name: data.d[i]["training_title"], startDate: Date.now(),endDate: new Date(2019, 4, 29) }
// add the item to the target array
target.push(item);
}
$('#calendar').calendar({
enableContextMenu: true,
enableRangeSelection: true,
dataSource: target // use the target array as events' datasrouce
})
Best regards,
Ackerly Xu
MSDN Community Support
Please remember to click "Mark as Answer" the responses that resolved your issue.
If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.
I find your returned data is of type string not an array , you could refer to my picture.
You could see my data.d shows Array(1) , yours is string, so it loops through the string. I guess the string's length is 100.
You should return an object from your service.
Below is my service.
[WebMethod]
public List<TrainingDates> HelloWorld(int user_id)
{
var TDates = new List<TrainingDates>();
var dates = new TrainingDates
{
training_title = "Induction Workshop has been scheduled on 27th – 29th March 2019",
date = "2/24/2019 12:00:00 AM"
};
TDates.Add(dates);
return TDates;
} public class TrainingDates { public string training_title { get; set; } public string date { get; set; } }
You should return data of type List<TrainingDates>.
Best regards,
Ackerly Xu
MSDN Community Support
Please remember to click "Mark as Answer" the responses that resolved your issue.
If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.
Your console shows you are using fullcalendar instead of bootstrap-calendar.
If you want to use bootstrap-calendar please change fullCalendar to calendar and import your bootstrap-year-calendar.css and bootstrap-year-calendar.js
$('#calendar').calendar({
enableContextMenu: true,
enableRangeSelection: true,
dataSource: target // use the target array as events' datasrouce
})
Best regards,
Ackerly Xu
MSDN Community Support
Please remember to click "Mark as Answer" the responses that resolved your issue.
If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.
You should parse your datastring to data of type date.
Below is my code.
// define a function to parse string to date
function parseStringToDate(dateString) {
// get year , month and day
var ymd = dateString.split(" ")[0].split("/");
var mydate = new Date(parseInt(ymd[2]), parseInt(ymd[0])-1, parseInt(ymd[1]))
return mydate;
}
$(function () {
$.ajax({
type: "POST",
url: "/Services/MyService.asmx/HelloWorld",
async:false,
data: JSON.stringify({ user_id: 1006 }),
contentType: "application/json",
datatype: "json",
success: function (data) {
var target = [];
// loop through data.d array
for (var i = 0; i < data.d.length; i++) {
var item = { name: data.d[i]["training_title"], startDate:parseStringToDate(data.d[i]["date"]) , endDate:parseStringToDate(data.d[i]["date"]) }
// add the item to the target array
target.push(item);
}
$('#calendar').calendar({
enableContextMenu: true,
enableRangeSelection: true,
dataSource: target // use the target array as events' datasrouce
})
},
error: function (XMLHttpRequest, textStatus, errorThrown) {
}
});
})
Best regards,
Ackerly Xu
MSDN Community Support
Please remember to click "Mark as Answer" the responses that resolved your issue.
If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.
Participant
1445 Points
2835 Posts
Show date and event title in full calender div : Jquery
Feb 28, 2019 04:55 AM|demoninside9|LINK
Hi All,
I have already populated a full calender div on my page.
And I am getting data through a webservice likde below.
The format I recieved data in json format like below.
Now I want to show this data in calender with title.
As I am new to jquery please suugest.
Thanks
Contributor
3500 Points
1300 Posts
Re: Show date and event title in full calender div : Jquery
Feb 28, 2019 07:56 AM|Ackerly Xu|LINK
Hi demoninside9,
You could try the code below .
Here is use Array.prototype.map function to map the returned data, if you are not familiar with it , you could refer to https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map
Best regards,
Ackerly Xu
Please remember to click "Mark as Answer" the responses that resolved your issue.
If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.
Participant
1445 Points
2835 Posts
Re: Show date and event title in full calender div : Jquery
Feb 28, 2019 08:59 AM|demoninside9|LINK
I tried your code, I am getting the alert with data. I put the same key name which I am getting in my json data.
BUt it is not showing in calendar. I dig out it by putting a break point but it doesn't show data. Although I still get data in alert message box.
Please suggest.
Thanks
Contributor
3500 Points
1300 Posts
Re: Show date and event title in full calender div : Jquery
Mar 01, 2019 01:15 AM|Ackerly Xu|LINK
Hi demoninside9,
You set a break point at the place where data hasn't been defined and the date is in a function which is hard to check, please set a break point at 1425 line to see the data.
And you could see my code is start not date , it matters because full calendar doesn't recognize date ,.
data = data.d.map(function (e) { return {title:e["training_title"],start:e.date} })
Below is my break point.
Best regards,
Ackerly Xu
Please remember to click "Mark as Answer" the responses that resolved your issue.
If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.
Participant
1445 Points
2835 Posts
Re: Show date and event title in full calender div : Jquery
Mar 01, 2019 04:08 AM|demoninside9|LINK
If I put debugger on top then break point doesn't come inside map function, instead it goes to the close tag of script means </script>.
Then I place debugger here and see the result below.
Thanks
Contributor
3500 Points
1300 Posts
Re: Show date and event title in full calender div : Jquery
Mar 01, 2019 04:17 AM|Ackerly Xu|LINK
Hi demoninside9,
As you could see , e is the parameter of the function that you have passed to map method, so if you remove the function , it will show the error.
If you want to debug the map method , please don't directly return the result, please write as follows.
data = data.d.map(function (e) { var obj = {title:e["training_title"],start:e.date} return obj; })
Best regards,
Ackerly Xu
Please remember to click "Mark as Answer" the responses that resolved your issue.
If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.
Participant
1445 Points
2835 Posts
Re: Show date and event title in full calender div : Jquery
Mar 01, 2019 04:25 AM|demoninside9|LINK
Yes, data is coming in data but not mapping/showing in calendar.
Am I making some mistake in code to show the data in calendar?
Contributor
3500 Points
1300 Posts
Re: Show date and event title in full calender div : Jquery
Mar 01, 2019 04:35 AM|Ackerly Xu|LINK
Hi demoninside9,
If you don't want to use map method, you could refer to the code below, manually loop through the array and set data.
Best regards,
Ackerly Xu
Please remember to click "Mark as Answer" the responses that resolved your issue.
If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.
Participant
1445 Points
2835 Posts
Re: Show date and event title in full calender div : Jquery
Mar 01, 2019 05:05 AM|demoninside9|LINK
My data has only one item, but data.d.length shows 117. \
So it loops 117 times. any why.. after that it shows that there fullcalendar is not a function
Contributor
3500 Points
1300 Posts
Re: Show date and event title in full calender div : Jquery
Mar 01, 2019 05:10 AM|Ackerly Xu|LINK
Hi demoninside9,
Have you import fullcalendar.js in your head?
And how you call the fullCalendar function?
$('#calendar').fullCalendar({ editable: false, events: target // use the target array as events' datasrouce })
Best regards,
Ackerly Xu
Please remember to click "Mark as Answer" the responses that resolved your issue.
If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.
Participant
1445 Points
2835 Posts
Re: Show date and event title in full calender div : Jquery
Mar 01, 2019 05:20 AM|demoninside9|LINK
I am populating full calendar by using bootstrap-year-calendar.
Contributor
3500 Points
1300 Posts
Re: Show date and event title in full calender div : Jquery
Mar 01, 2019 06:08 AM|Ackerly Xu|LINK
Hi demoninside9,
I'm sorry , I don't know you are using bootstarp calendar instead of fullcalendar.
I have found one in below link.
https://codepen.io/anon/pen/jJWywP?editors=1111
And it seems that you should set startDate and endDate, if you are using bootstarp calendar
I have found little resource about the plugin , could your share your link that withe bootstarp calendar?
You say you have not seen event on 26th using full calendar , could you debug your code and see that data.d is?As you could see , other date shows well.
Best regards,
Ackerly Xu
Please remember to click "Mark as Answer" the responses that resolved your issue.
If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.
Participant
1445 Points
2835 Posts
Re: Show date and event title in full calender div : Jquery
Mar 01, 2019 08:39 AM|demoninside9|LINK
You not need to say sorry. I forgot to mention in the post.
Show
Here is the link from where I get the bootstrap full year calendar.
http://www.bootstrap-year-calendar.com/#Examples/Full%20example
Contributor
3500 Points
1300 Posts
Re: Show date and event title in full calender div : Jquery
Mar 01, 2019 09:19 AM|Ackerly Xu|LINK
Hi demoninside9,
undefined means you haven't get the value, how do you get the name?
I write
I need to know what you data looks like.
Best regards,
Ackerly Xu
Please remember to click "Mark as Answer" the responses that resolved your issue.
If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.
Participant
1445 Points
2835 Posts
Re: Show date and event title in full calender div : Jquery
Mar 01, 2019 09:40 AM|demoninside9|LINK
Contributor
3500 Points
1300 Posts
Re: Show date and event title in full calender div : Jquery
Mar 01, 2019 10:00 AM|Ackerly Xu|LINK
Hi demoninside9,
It's strange , there is only one item , the array should not contain so many elements.
Could you show me all your js code?
Best regards,
Ackerly Xu
Please remember to click "Mark as Answer" the responses that resolved your issue.
If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.
Participant
1445 Points
2835 Posts
Re: Show date and event title in full calender div : Jquery
Mar 01, 2019 11:25 AM|demoninside9|LINK
Boss, it is too lengthy, but still I am sharing. My block is the last one in down side.
Participant
1445 Points
2835 Posts
Re: Show date and event title in full calender div : Jquery
Mar 01, 2019 11:54 AM|demoninside9|LINK
I guess the array takes other data which is resides on my page itself .
Actually I can not make a new page for my purpose. Otherwise it would have not hard to nail.
There are already many functionality running. I did not created this page. But I need add my services data in the same calendar.
Thanks
Participant
1253 Points
936 Posts
Re: Show date and event title in full calender div : Jquery
Mar 01, 2019 12:19 PM|yogyogi|LINK
In your success callback you can do this:
Now you can simply bind this date to your calendar.
♠ ASP.NET Core Tutorials → Start from the Beginning and become an Expert in 30 days time ♠
Contributor
3500 Points
1300 Posts
Re: Show date and event title in full calender div : Jquery
Mar 04, 2019 01:38 AM|Ackerly Xu|LINK
Hi demoninside9,
I see you function that retrieve data is
It is different from your original code.
I think you could debug your code to check your array of data after the ajax call returns.
I wonder it is not an empty array.
$.ajax({ type: "POST", url: "/Services/MyService.asmx/HelloWorld", data: JSON.stringify({ user_id: 1006 }), contentType: "application/json", datatype: "json", success: function (data) { // here debug to see your array var target = []; // loop through data.d array for (var i = 0; i < data.d.length; i++) { //get training_title and set to an object's title property ,get date and set the object's start property to date. var item = { name: data.d[i]["training_title"], startDate: Date.now(),endDate: new Date(2019, 4, 29) } // add the item to the target array target.push(item); } $('#calendar').calendar({ enableContextMenu: true, enableRangeSelection: true, dataSource: target // use the target array as events' datasrouce })
Best regards,
Ackerly Xu
Please remember to click "Mark as Answer" the responses that resolved your issue.
If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.
Participant
1445 Points
2835 Posts
Re: Show date and event title in full calender div : Jquery
Mar 04, 2019 08:07 AM|demoninside9|LINK
This is separate one.
I have written another scrip block to call my webservice.
Is getMyData() interrupting my new ajax fucntion?
Contributor
3500 Points
1300 Posts
Re: Show date and event title in full calender div : Jquery
Mar 04, 2019 08:54 AM|Ackerly Xu|LINK
Hi demoninside9,
I find your returned data is of type string not an array , you could refer to my picture.
You could see my data.d shows Array(1) , yours is string, so it loops through the string. I guess the string's length is 100.
You should return an object from your service.
Below is my service.
You should return data of type List<TrainingDates>.
Best regards,
Ackerly Xu
Please remember to click "Mark as Answer" the responses that resolved your issue.
If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.
Participant
1445 Points
2835 Posts
Re: Show date and event title in full calender div : Jquery
Mar 04, 2019 10:53 AM|demoninside9|LINK
Yes, I did the same as you suggested.
Now I am getting only one item in array. But not showing in calendar.
And when I try go ahead by pressing F10 it shows a red point on the below line and goes into jquery file code.
here is shows the red point and immoderately goes into jquery
And in console it shows the following error
Contributor
3500 Points
1300 Posts
Re: Show date and event title in full calender div : Jquery
Mar 05, 2019 01:18 AM|Ackerly Xu|LINK
Hi demoninside9,
Your console shows you are using fullcalendar instead of bootstrap-calendar.
If you want to use bootstrap-calendar please change fullCalendar to calendar and import your bootstrap-year-calendar.css and bootstrap-year-calendar.js
$('#calendar').calendar({ enableContextMenu: true, enableRangeSelection: true, dataSource: target // use the target array as events' datasrouce })
Best regards,
Ackerly Xu
Please remember to click "Mark as Answer" the responses that resolved your issue.
If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.
Participant
1445 Points
2835 Posts
Re: Show date and event title in full calender div : Jquery
Mar 05, 2019 03:40 AM|demoninside9|LINK
Yes, It works.
I am almost done. My requirement is that my start date and end date should be equal.
form this line
Give the below output.
When I try to modify it to make both dates same like below.
It doesn't show.
Thanks
Contributor
3500 Points
1300 Posts
Re: Show date and event title in full calender div : Jquery
Mar 05, 2019 05:53 AM|Ackerly Xu|LINK
Hi demoninside9,
You should parse your datastring to data of type date.
Below is my code.
Best regards,
Ackerly Xu
Please remember to click "Mark as Answer" the responses that resolved your issue.
If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.
Participant
1445 Points
2835 Posts
Re: Show date and event title in full calender div : Jquery
Mar 05, 2019 06:07 AM|demoninside9|LINK
Thank you... Thank you so much Ackerly Xu. You just made my day.
This is what I wanted.
Thanks again for giving your valuable time on this post.