how to load() a template file, then pass it as a variable or do an alert test
I am using php, and need to load() this , template content php file into the jquery and pass it to a #div ID to render front-end view.
I am not sure how to load the php file in jquery and then pass it as a variable called repeater which helps build out all the rows combining the template loaded with Ajax (obj) query results.
In the set alert, it pops up as [object Object], no template.
When I write the entire php template content out into jquery as var repeater, it works, but I do not want all that html in jquery. Just load() then read.
Here is the code if this makes any sense
Code:
$('#pageContent').load('../includes/OrderLookup.php #pageContent');
alert ($('#pageContent').load('OrderLookup.html #pageContent'));
var url = $('#pageContent').load('../includes/OrderLookup.php');
var page = '<div id="pageContent"></div>';
var repeater = $('#pageContent').load('OrderLookup.html #pageContent');
var pageBuildUp='';
for (x in dataArray){
pageBuildUp += obj.repeater;
//alert(obj.repeater);
//pageBuildUp += url;
pageBuildUp = pageBuildUp.replace('##transactionId##',makeTextSmall(dataArray[x]['blockvalue'],20));
if (dataArray[x]['description']==''){
pageBuildUp = pageBuildUp.replace('##orderTotal##','no total amount');
}
I changed my code some. Using function(dataRow), I can gather the Temlate file.
But problem now is the function cannot be inside of the Main function and work properly.
How to wrap that function with my current loop pagebuildup function?
Code:
$.post("ajax/search_full_block.php",{query:searchQuery,limit:limiter,accountID:accountID,blocktype:block_type,emailID:emailID},function(dataReturn){
var obj = jQuery.parseJSON(dataReturn);
alert('---success---');
if (obj.Ack=="success"){
$('#resultsset').html('');
var dataArray = obj.data;
var totalCount = obj.total_count;
var optionsBloc='';
var repeater = $('#pageContent').load('includes/OrderLookup.php');
alert($("#pageContent").html(repeater));
var page = '<div id="pageContent"></div>';
$('#pageContent').load("includes/OrderLookup.php", function(dataRow) {
alert("Data Loaded: " + dataRow);
var repeater = dataRow;
});
var pageBuildUp='';
for (x in dataArray){
pageBuildUp += obj.repeater;
pageBuildUp = pageBuildUp.replace('##transactionId##',makeTextSmall(dataArray[x]['blockvalue'],20));
if (dataArray[x]['description']==''){
pageBuildUp = pageBuildUp.replace('##orderTotal##','no total amount');
}
Bookmarks