function jWdGetTranslationOnSuccess(resultData) {
var searchResultWithNextPageNumber = resultData.split('~');
var nextPageNumber = searchResultWithNextPageNumber[1];
var searchResultData = JSON.parse(searchResultWithNextPageNumber[0]);
var recoudCount = searchResultData.length;
/* Loop on searchResultData and append to list ul */
if (recoudCount > 0) {
for (var i = 0; i < recoudCount; i++) {
$('#list').append('<li> ' + searchResultData[i].Item + ' </li>');
}
$('#list').listview('refresh');
}
// IF not searchResultData then show data not found message
else {
$("#div_ShowMsg").show();
}
/* If next page number is 0 then hide the Show more button */
if (nextPageNumber > 1) {
/*Create the dynamic button and add to div of show more */
var btn = "<a onclick='return jWdShowNextPage("
btn += nextPageNumber;
btn += ");' class='showMore showMore-corner-all showMore-shadow' title=";
btn += '<%= GetLocalResourceObject("btnShowMoreToolTip") %>>';
btn += '<%=GetLocalResourceObject("btnShowMoreText") %>';
btn += "</a>";
$("#showMore").html(btn);
$("#showMore").show();
}
else {
$("#showMore").hide();
}
} // jWdGetTranslationOnSuccess
function jWdFail(resultError) {
alert(resultError);
}
function jWdShowNextPage(nextPageNumber) {
$("#div_ShowMsg").hide();
var txtSearchText = $("#<%= txtSearchText.ClientID %>")
var activeDictionaryType = '<%=ActiveDictionaryType %>';
var baseCultureId = '<%=BaseCultureId %>';
var targetCultureId = '<%=TargetCultureId %>';
var pageSize = '<%= GetGlobalResourceObject("mta","pageSize") %>'
// Call the web service
WebDirekt.WebServices.Translation.GetTranslation(activeDictionaryType, baseCultureId, targetCultureId, txtSearchText[0].value, nextPageNumber, pageSize, jWdGetTranslationOnSuccess, jWdFail);
return false;
} //jWdShowNextPage
a.hole
Member
1 Points
6 Posts
Calling Web service twice or more when enter keyword button twice or more
Apr 03, 2012 06:16 AM|LINK
Hello
I want to prevent calling web service twice or more when enter keyword button twice or more
So how to prevent it.
My code like this
function jWDGetTranslation() {
$("#div_ShowMsg").hide();
$("#showMore").hide();
$('#list').empty();
var txtSearchText = $("#<%= txtSearchText.ClientID %>")
var activeDictionaryType = '<%=ActiveDictionaryType %>';
var baseCultureId = '<%=BaseCultureId %>';
var targetCultureId = '<%=TargetCultureId %>';
var pageSize = '<%= GetGlobalResourceObject("mta","pageSize") %>'
if (txtSearchText[0].value != '') {
WebDirekt.WebServices.Translation.GetTranslation(activeDictionaryType, baseCultureId, targetCultureId, txtSearchText[0].value, 1, pageSize, jWdGetTranslationOnSuccess, jWdFail);
}
else {
$('#list').empty();
$("#div_ShowMsg").show();
}
return false;
} // jWDGetTranslation
function jWdGetTranslationOnSuccess(resultData) {
var searchResultWithNextPageNumber = resultData.split('~');
var nextPageNumber = searchResultWithNextPageNumber[1];
var searchResultData = JSON.parse(searchResultWithNextPageNumber[0]);
var recoudCount = searchResultData.length;
/* Loop on searchResultData and append to list ul */
if (recoudCount > 0) {
for (var i = 0; i < recoudCount; i++) {
$('#list').append('<li> ' + searchResultData[i].Item + ' </li>');
}
$('#list').listview('refresh');
}
// IF not searchResultData then show data not found message
else {
$("#div_ShowMsg").show();
}
/* If next page number is 0 then hide the Show more button */
if (nextPageNumber > 1) {
/*Create the dynamic button and add to div of show more */
var btn = "<a onclick='return jWdShowNextPage("
btn += nextPageNumber;
btn += ");' class='showMore showMore-corner-all showMore-shadow' title=";
btn += '<%= GetLocalResourceObject("btnShowMoreToolTip") %>>';
btn += '<%=GetLocalResourceObject("btnShowMoreText") %>';
btn += "</a>";
$("#showMore").html(btn);
$("#showMore").show();
}
else {
$("#showMore").hide();
}
} // jWdGetTranslationOnSuccess
function jWdFail(resultError) {
alert(resultError);
}
function jWdShowNextPage(nextPageNumber) {
$("#div_ShowMsg").hide();
var txtSearchText = $("#<%= txtSearchText.ClientID %>")
var activeDictionaryType = '<%=ActiveDictionaryType %>';
var baseCultureId = '<%=BaseCultureId %>';
var targetCultureId = '<%=TargetCultureId %>';
var pageSize = '<%= GetGlobalResourceObject("mta","pageSize") %>'
// Call the web service
WebDirekt.WebServices.Translation.GetTranslation(activeDictionaryType, baseCultureId, targetCultureId, txtSearchText[0].value, nextPageNumber, pageSize, jWdGetTranslationOnSuccess, jWdFail);
return false;
} //jWdShowNextPage
<asp:TextBox ID="txtSearchText" runat="server" onblur="trim(this);" MaxLength="256"></asp:TextBox>
<ul id="list" data-role="listview" data-inset="true"></ul>
<div id="showMore">
</div>
<asp:LinkButton ID="lnkBtnSearch" runat="server" data-transition="slide" data-theme="a" meta:resourcekey="lnkBtnSearch" data-icon="arrow-r" data-role="button" data-iconpos="right" OnClientClick="return jWDGetTranslation();" CssClass="lnkBtnCss" />
When i enter the text and enter keyboard button twice or more then it call web service twice or more
so how i prevent the calling web service multiple time when i enter the my default search button