jquery to construct a string and pass it as a post argument for file
Posted
by user253530
on Stack Overflow
See other posts from Stack Overflow
or by user253530
Published on 2010-03-16T23:06:01Z
Indexed on
2010/03/16
23:11 UTC
Read the original article
Hit count: 266
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");
});
© Stack Overflow or respective owner