I'm new to SharePoint and JSOM and i'm trying to build up a search using JSOM.
and i tried below code snippets
I FOLLOWED FOLLOWING BLOG http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/2013/04/18/how-to-query-search-with-the-sharepoint-2013-javascript-client-object-model.aspx
Is there any search.js
file i should linked? if so what would be the link??
However these are the links i added
1st step: Create a page and added following HTML
It has search button : #searchButton
and text box : #searchTextBox
i linked JQuery and abc.js
file succesfully
and added this JS code to abc.js file
'use strict';
var results;
var context = SP.ClientContext.get_current();
var user = context.get_web().get_currentUser();
$(document).ready(function () {
$("#searchButton").click(function () {
alert('check1');
var keywordQuery = new Microsoft.SharePoint.Client.Search.Query.KeywordQuery(context);
keywordQuery.set_queryText($("#searchTextBox").val());
alert('check2');
var searchExecutor = new Microsoft.SharePoint.Client.Search.Query.SearchExecutor(context);
results = searchExecutor.executeQuery(keywordQuery);
context.executeQueryAsync(onQuerySuccess, onQueryFail)
});
});
function onQuerySuccess() {
$("#resultsDiv").append('<table>');
$.each(results.m_value.ResultTables[0].ResultRows, function () {
$("#resultsDiv").append('<tr>');
$("#resultsDiv").append('<td>' + this.Title + '</td>');
$("#resultsDiv").append('<td>' + this.Author + '</td>');
$("#resultsDiv").append('<td>' + this.Write + '</td>');
$("#resultsDiv").append('<td>' + this.Path + '</td>');
$("#resultsDiv").append('</tr>');
});
$("#resultsDiv").append('</table>');
}
function onQueryFail(sender, args) {
alert('Query failed. Error:' + args.get_message());
}
In this code check1 alert is coming but not the check2 alert.. Whats the wrong with this..?
Please help me
MasterPage
======================== i've uplaoded the apex page here
https://www.zeta-uploader.com/606022001