jquery to construct a string and pass it as a post argument for file
- by user253530
I have this js code:
$("#startSearch").live("click", function(event){
$("input:checkbox[name='searchId']:checked").each(function(){
var searchId = $(this).val();
var host = '';
$.post("php/autosearch-get-host.php",{sId: searchId},function(data){
host = 'http://' + data + '/index.php';
});
//alert(host);
$.getJSON(host,{searchId: $(this).val()},function(){
pagination("php/pagination.php", $('#currentPage').val(), $('#sortBy').val(), $("#sortMode").val(), "autosearch");
});
});
});
The php file php/autosearch-get-host.php returns a string with the host name. What i want is to get the host from the database, create the URL using string concatenation and pass it as an argument to another $.post. $.post should use that URL like this:
$.getJSON(host,{searchId: $(this).val()},function()
{
pagination("php/pagination.php", $('#currentPage').val(), $('#sortBy').val(), $("#sortMode").val(), "autosearch");
});