TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Praveen Kumar
NA
60
2.4k
how to handle null point exception?
Aug 6 2018 4:08 AM
$(document).ready(
function
(){
try
{
ExecuteOrDelayUntilScriptLoaded(downloads,
"sp.js"
);
}
catch
(e)
{
alert(JSON.stringify(e));
}
});
function
downloads() {
var
pagename = window.location.href.split(
'/'
).reverse()[0];
$.ajax({
url: _spPageContextInfo.webAbsoluteUrl +
"/_api/web/lists/getByTitle('DownloadLinks')/items?$filter=CategoryDownload eq '"
+ pagename +
"'&$orderby=Order_ID asc"
,
type:
"GET"
,
headers: {
"accept"
:
"application/json;odata=verbose"
,
"content-type"
:
"application/json;odata=verbose"
,
},
success: DownloadLinksSucceeded,
error: DownloadLinksFailed
});
}
var
results1;
var
banner;
function
DownloadLinksSucceeded(data) {
console.log(data);
results1 =data.d.results;
var
htmlString=
"<div class='Category_heading'><h2 class='Category_heading1'>DOWNLOADS</h2></div>"
;
htmlString+=
"<ul class='no_bullet text'>"
;
for
(
var
i=0; i< results1.length; i++){
var
item1= results1[i];
htmlString +=
'<li class="image">'
;
htmlString +=
'<a nowrap class="link_tag" href="'
+ results1[i].DownloadURL.Url +
'">'
;
htmlString += results1[i].Title;
if
(results1[i].Banner_Image.Url!=
null
)
{
var
banner=results1[i].Banner_Image.Url;
htmlString +=
'<img class="baner_image" src="'
+banner+
'" alt="">'
;
}
else
{
alert(
'hello'
);
}
htmlString +=
'</a>'
;
htmlString+=
'</li>'
;
//htmlString += '<a class="link_tag" href="'+ results1[i].DownloadURL.Url +'">'+ results1[i].Title +'</a>';
}
htmlString+=
"</ul>"
;
$(
"#download1"
).html(htmlString);
}
function
DownloadLinksFailed() {
alert(
'Sorry An Error Has Occurred!'
);
}
Attachment:
New_Text_Document.zip
Reply
Answers (
8
)
SharePoint Paging using Numbers in JSOM
SharePoint Online to NewGen Migration