ggalan
12-07-2011, 12:22 AM
im using jQuery's post for some ajax calls and get a callback from my php file using echo then in jQuery data to represent that echo.
question: how can i have multiple variables from php to jQuery?
do i need to make an array to json file?
jQuery:
$('.myClass').click(function() {
var itm = $(this).find('textarea[class=typeItem]');
var txt = $(this).find('textarea[class=typeTxt]');
$.post( 'action.php', {itemType:itm, entryItm:txt}, function(data, otherData, moreData){
$('ul#mylist).append("<li class='default'>'" + txt + " " + data + otherData + moreData +"'</li>");
});
}
php:
<?php
$type = $_POST['itemType'];
$nTitle = $_POST['entryItm'];
// some code
echo var1; // data
echo var2; // otherData
echo var3; // moreData
?>
question: how can i have multiple variables from php to jQuery?
do i need to make an array to json file?
jQuery:
$('.myClass').click(function() {
var itm = $(this).find('textarea[class=typeItem]');
var txt = $(this).find('textarea[class=typeTxt]');
$.post( 'action.php', {itemType:itm, entryItm:txt}, function(data, otherData, moreData){
$('ul#mylist).append("<li class='default'>'" + txt + " " + data + otherData + moreData +"'</li>");
});
}
php:
<?php
$type = $_POST['itemType'];
$nTitle = $_POST['entryItm'];
// some code
echo var1; // data
echo var2; // otherData
echo var3; // moreData
?>