Beginner javascript newbie - wants to learn some basics - display results from php query
| From: | dealTek | Date: | Sat, 02 May 2015 20:48:40 +0000 |
| Subject: | Beginner javascript newbie - wants to learn some basics - display results from php query | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-324850@lists.php.net to get a copy of this message | ||
[OFF TOPIC]
Hi all,
I know this is not a javascript forum - but could use some basic javascript beginner help or
URL's to get started...
Beginner javascript newbie - wants to learn some basics - display results from php query
example...
Q: If I request just a single record result - like query ends with - print_r (json_encode($output));
how can I display various fields at different areas of the page using javascript query result?
With php I can display a field output like:
html ...
html ...
<?php echo $record->getField('FirstName'); ?>
html ....
html ...
Q: So how do I convert the PHP query result - print_r (json_encode($output)); - to place php field
results randomly where I want mixed in with html?
First Name is: <?php echo $record->getField('FirstName'); ?> <br />
- ?CAN I JUST PUT FirstName here using javascript not php like ... <???JAVASCRIPT field ???>
FirstName <???/JAVASCRIPT ???>
Last Name is: <?php echo $record->getField('FirstName'); ?><br />
Phone is: <?php echo $record->getField('Phone'); ?><br />
Street is: <?php echo $record->getField('Street'); ?><br />
etc.
=================
WHAT I HAVE in javascript - works but it forces me to put the html inside the script so whole thing
inside ...........
<script>
$(document).ready(function(){
$("button").click(function(){
$.get("getstuff.php", function(data, status){
// alert("Data: " + data + "\nStatus: " + status);
console.log ('data', data);
output = "";
$.each(data, function(key, value) {
console. log ('item', key, value);
output += " Name is: " + value.FirstName + " " + value.LastName +
"<br>";
});
$('#list').html( output );
$('#list').listview( "refresh" );
});
});
});
</script>
--
Thanks,
Dave - DealTek
dealtek@gmail.com
[db-15]