Last active
August 29, 2015 14:20
-
-
Save kurtisdunn/0e46d9ddc4f945f6bed5 to your computer and use it in GitHub Desktop.
Adobe BC Site Search AJAX
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$('.search-input button').on('click touchstart',function(e) { | |
e.preventDefault(); | |
var query = $("#CAT_Search").val(); | |
$.ajax({ | |
type: 'POST', | |
url: "http://dampiercommunityassociation.worldsecuresystems.com/Default.aspx?A=SiteSearch&PageID =16061029&SSQID=507267&SiteSearchID=3145&CAT_Search="+query+"&SE=True", | |
dataType: "html", | |
success: function(data) { | |
var results = $(data).find('.search-result'); | |
var pagPrev = $(data).find('#searchprev'); | |
var pagNext = $(data).find('#searchnext'); | |
if ( data.indexOf('No results found matching your query') > -1 ) { | |
$('.search-container').append("<p>Uh Oh! We couldnt quite find <span>" + query + "</span>.") | |
$('.search-input > input').val(query.toString()); | |
$('#searchFrame').modal('show'); | |
$(results).each(function(){ | |
var tpl = $(this).wrap('<p>').parent().one().html(); | |
$('.search-container').append(tpl) | |
}); | |
if(!pagPrev.context){$('#pagPrev').attr('disabled', 'disabled');} | |
else{ $('#pagPrev').attr('href', $(pagPrev).attr('href'));} | |
if(pagNext){$('#pagNext').attr('href', $(pagNext).attr('href'));} | |
results.empty(); | |
}, | |
error: function(err) { | |
console.log('err', err) | |
} | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment