View Single Post
Old 02-24-2010, 05:01 PM  
Jakez
Confirmed User
 
Jakez's Avatar
 
Industry Role:
Join Date: Jan 2004
Location: oddfuturewolfgangkillthemall!!!!!!!
Posts: 5,656
Ok I managed to get something extremely simplified so that even I can understand it and someone can hopefully understand what I'm trying to do lol. Only one problem I have. I want the jQuery to just display whatever the PHP sends back to it, instead of having to go through all the json crap and having the jQuery handle what gets shown. Ex (I use tabs so the indents are gone sry):

The js/jquery:
Quote:
<script type="text/javascript">
function readPage(keyPage, jsNum, aNum)
{
if(aNum==1)
{
$(document).ready(function()
{
$.post("ajaxwork.php?a=import_videos", $("#target").serialize(),
function(data){$("#ajaxCol"+jsNum).html(data.delim iter);}, "json");
});
}
}
</script>
The HTML:
Quote:
<form id="target" action="javascript:readPage('page.php?a=do_this', 1, 1);">
Delimiter: <input name="delimiter" value="|" size=1><br>
<input type=submit value="Next">
</form>

<div id="ajaxCol1" style="display:inline;"></div>
And the PHP:
Quote:
<?php
if($_GET['a']=="do_this")
{
$return_json = "{'delimiter':'".$_POST['delimiter']."'}";
echo $return_json;
}
?>
Should I just change the:
$return_json = "{'delimiter':'".$_POST['delimiter']."'}";

and make it send all the HTML/etc I want to display? Like:
$everything="<b>blah blah blah ".$_POST['delimiter']."</b>";
$return_json = "{'everything':'$everything'}";

Edit: it works^ I guess I will just do it that way, but idk if it's the wrong way or it doesn't matter or what. I just don't want to handle all the printing and HTML in jquery because it's really going to clutter a lot of shit up. And having to rename all the $_POST's is just stupid imo I don't really understand the whole json thing.
__________________
[email protected] - jakezdumb - 573689400

Killuminati

Last edited by Jakez; 02-24-2010 at 05:15 PM..
Jakez is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote