Skip to main content

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

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

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..?

added 137 characters in body
Source Link

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

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

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

added 176 characters in body
Source Link
Arsalan Adam Khatri
  • 14.5k
  • 3
  • 37
  • 59

I'm new to SharepointSharePoint and jsomJSOM and i'm trying to build up a search using JSOM.

and i tried below code snipptssnippets

I FOLLOWED FOLLWINGFOLLOWING 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.jssearch.js file i should linked? if so what would be the link?? However these are the links i added

It has search button : #searchButton#searchButton and text box : #searchTextBox#searchTextBox

i linked jqueryJQuery and abc.jsabc.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 () {

'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('');

 
 
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());
}

}

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

Thank you very very much

I'm new to Sharepoint and jsom and i'm trying to build up a search using JSOM.

and i tried below code snippts

I FOLLOWED FOLLWING 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

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('');

$.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

Thank you very very much

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

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

deleted 63 characters in body; edited tags
Source Link
Loading
added 138 characters in body; edited tags
Source Link
Nadeem Yousuf-AIS
  • 18.7k
  • 4
  • 29
  • 59
Loading
Source Link
Loading