Using Ajax to get HTML total results
Moderator: General Moderators
Using Ajax to get HTML total results
Hi all
I am using xmlHTTP function block to retrieve the innerHTML to a DIV . I also have Paging option to the results.
My problem is to Retrieve the Total num of rows from the Server Side into the INNER DIV NOT As an HTML format .
I need this Num rows number just to let my clientside know how many rows left to show.
How can i implement it ?
Thanks
Moshe
I am using xmlHTTP function block to retrieve the innerHTML to a DIV . I also have Paging option to the results.
My problem is to Retrieve the Total num of rows from the Server Side into the INNER DIV NOT As an HTML format .
I need this Num rows number just to let my clientside know how many rows left to show.
How can i implement it ?
Thanks
Moshe
- superdezign
- DevNet Master
- Posts: 4135
- Joined: Sat Jan 20, 2007 11:06 pm
You could obtain the total number of rows from the server side script and just add it to the AJAX code, assuming you are using more than just AJAX.
Code: Select all
var numOfRows=<?=$numOfRows?>;Ajax + js code
Hi
so Should i write in the server side :?
so Should i write in the server side :
Code: Select all
<script language=javascript>var numrows=<?=222;?>;</script> Ajax + js code
Hi
Its not working. let me explain my code again :
I have a main page that user JS function that calls xmlHTTP Object to a URL in server side (server.php)
I need the NumRows to be avaliable in this main file .
in the Server.php file i added :
and in the main js script i use:
and it returns undefined.
any suggestion ?
Thanks again
Moshe
Its not working. let me explain my code again :
I have a main page that user JS function that calls xmlHTTP Object to a URL in server side (server.php)
I need the NumRows to be avaliable in this main file .
in the Server.php file i added :
Code: Select all
print "<script language=javascript>var NumRows=3</script>";Code: Select all
alert(NumRows);any suggestion ?
Thanks again
Moshe
-
nickvd
- DevNet Resident
- Posts: 1027
- Joined: Thu Mar 10, 2005 5:27 pm
- Location: Southern Ontario
- Contact:
The best thing to do is to return a JSON string, which gets eval()'d on the client side (preferably using a javascript based json parser to avoid eval() usage).
The string would be returned as such:
You would eval() (or parse it) in your callback function.
You could then access the data.
The string would be returned as such:
Code: Select all
{
'myvar' : 'myvalue',
'text' : 'all your html are belong to us'
}Code: Select all
eval('var returnData = ' + thedatayoureturned);Code: Select all
alert(returnData.myvar);Ajax + js code
hi
Sorry i dont know which part to put in the client side code and which in the serverside code ?
Thanks
Moshe
Sorry i dont know which part to put in the client side code and which in the serverside code ?
Thanks
Moshe