Forums / Cotonti / Extensions / AJAX parts in plugs

urlkiller
#24294 2010-04-24 00:36
ok maybe so ;)

i got now the following problem when inserting html markup in my xml document it dont get parsed correctly.

seems like the .text() from juery is filtering out the whole markup like <h1> and such...

any ideas why it is breaking there?

Added 11 minutes later:

got it already was the cdata thing i was missing for the markup problem:
<![CDATA[".$msgrow['message']."]]>
$msgrow['message'] = sed_parse($msgrow['message']);
$msgrow['date'] = date('d.m.Y H:i:s',$msgrow['date']);
$msgrow['username'] = $msgrow['username'];
		
$sendToOut .= "\t<message>\n";
$sendToOut .= "\t\t<username>".$msgrow['username']."</username>\n";
$sendToOut .= "\t\t<userid>".$msgrow['userid']."</userid>\n";
$sendToOut .= "\t\t<date>".$msgrow['date']."</date>\n";
$sendToOut .= "\t\t<avatar>".$msgrow['avatar']."</avatar>\n";
$sendToOut .= "\t\t<messagebody><![CDATA[".$msgrow['message']."]]></messagebody>\n";
$sendToOut .= "\t</message>\n";

Added 16 minutes later:

hmm somehow it wont send the data when inserting new data over post.
i alwyays get a 930 back and get redirected ... ;( dont find the problem...

Added 3 minutes later:

ok to conclude this:

		$t->assign('MY_JS_FUNC', "$(document).ready(function(){
			timestamp = 0;
			updateMsg();
			$(\"form#myform\").submit(function(){
				$.post(\"plug.php?r=dashboard\",{
							message: $(\"#sendmessage\").val(),
							group_id: \"".$gid."\",
							user_id: \"".$usr['id']."\",
							x: \"".sed_sourcekey()."\",
							user_name: \"".$urow['user_name']."\",
							user_avatar: \"".$urow['user_avatar']."\",
							action: \"send\",
							time: timestamp
						}, function(xml) {
								addMessages(xml);
								$('#sendmessage').val('');
				});
				return false;
			});
		});");

											<form id="myform">
										 		<textarea class="minieditor" name="sendmessage" id="sendmessage"></textarea>
								 				<input type="submit" id="submiter" value="Absenden" style="margin-left:3px;padding:5px;font-size:12px;width:437px;">
								 			</form>

defined('SED_CODE') or die('Wrong URL');
// send header
sed_sendheaders();

$time 					= ($_SERVER['REQUEST_METHOD'] != 'GET') ? sed_import('time','P','INT') : sed_import('time','G','INT');
$action 				= ($_SERVER['REQUEST_METHOD'] != 'GET') ? sed_import('action','P','TXT') : sed_import('action','G','TXT');
$user_name 			= sed_import('user_name','P','TXT');
$user_avatar 		= sed_import('user_avatar','P','TXT');
$date_now 			= sed_import('time','P','TXT');
$user_id 				= sed_import('user_id','P','TXT');
$group_id 			= sed_import('group_id','P','TXT');
$message 			  = sed_import('message','P','TXT');

if($action == "send")
{
	$insert = sed_sql_query("INSERT INTO whiteBox_wave (`username`,`message`,`date`,`avatar`,`userid`,`groupid`) VALUES ('".$user_name."','".$message."','".$date_now."','".$user_avatar."','".$user_id."','".$group_id."')");
}

$msg = sed_sql_query("SELECT * FROM whiteBox_wave WHERE date>'".$time."' ORDER BY date ASC ");

if(sed_sql_numrows($msg) == 0) $status_code = 2;
else $status_code = 1;

$sendToOut .= "<?xml version=\"1.0\" ?>\n";
$sendToOut .= "<response>\n";
$sendToOut .= "\t<status>".$status_code."</status>\n";
$sendToOut .= "\t<time>".mktime()."</time>\n";
if($status_code == 1)
{
	while($msgrow = sed_sql_fetcharray($msg))
	{

		$msgrow['message'] 		= sed_parse($msgrow['message']);
		$msgrow['date'] 			= date('d.m.Y H:i:s',$msgrow['date']);
		$msgrow['username'] 	= sed_build_user($msgrow['userid'],$msgrow['username']);
		
		$sendToOut .= "\t<message>\n";
		$sendToOut .= "\t\t<username><![CDATA[".$msgrow['username']."]]></username>\n";
		$sendToOut .= "\t\t<userid>".$msgrow['userid']."</userid>\n";
		$sendToOut .= "\t\t<date>".$msgrow['date']."</date>\n";
		$sendToOut .= "\t\t<avatar>".$msgrow['avatar']."</avatar>\n";
		$sendToOut .= "\t\t<messagebody><![CDATA[".$msgrow['message']."]]></messagebody>\n";
		$sendToOut .= "\t</message>\n";
	}
}
$sendToOut .= "</response>";


header("Content-type: text/xml");
header("Cache-Control: no-cache");

echo $sendToOut;

ob_end_flush();


Added 45 minutes later:

its quite wierd. because i did yesterday something and today its not working anymore.
i guess i had smething working and deleted or changed it due to testing the parser thing so i think its only a minor problem with my code here..

but i think iam too blind today for seeing it..
URL shortener: <a href="http://bbm.li/!7AD5C7">http://bbm.li/!7AD5C7</a>
This post was edited by urlkiller (2010-04-24 02:06, 14 years ago)