Форумы / Cotonti / Development / sed_parse & ajax

hmmm

urlkiller
#1 16.04.2010 21:01
hey folks,

i got here a little problem. the implemented parses get me now some headache on when working with ajax contents.

my problem:

1. user submits a form (ajax jquery call) (works)
2. php file insert everything in db and should echo the contents (works)
3. content gets displayd (works)
4. bold / opblique etc wont show correctly formated.

it seems that the parses just dont work. so i thought it may wont work as a standalone ajax function because it need too much system variables the global includes in the function itself wont allow me to use this function in my NOT included ajax php file.

anybody some solution for this kind of problem?
URL shortener: <a href="http://bbm.li/!7AD5C7">http://bbm.li/!7AD5C7</a>
Trustmaster
#2 16.04.2010 21:35
Do you use and AJAX part of a plugin or have a root-level script? common.php is required for the parser to work (load all bbcodes), so I guess this is the problem. You can manually preload them with this:
sed_bbcode_load();
May the Source be with you!
urlkiller
#3 16.04.2010 21:44
ill give this a try giving me the headaches the last 4 days ;(

Added 33 seconds later:

currenty my includes look like this:

include('../../../../../datas/config.php');
include('../../../../../plugins/dashboard/inc/extconnect.php');
include('../../../../../system/database.mysql.php');
include('../../../../../plugins/dashboard/inc/functions.php');

and the script runs root level

Added 50 seconds later:

exconnect and functions includes most of the system/functions.php because it was somehow interrupting each other... (already definded bla bla bla)

Added 11 minutes later:

hmm seems that i got a major problem here.

the problem is that i dont have my test.php included in the main system.
i only include the system's functions, db connection, config and common so it wont work
because all variables get definded somewhere in the core system.

is there any secure workaround for something like this? or some alternative because the incldued ajax functions are a bit hard to understand without some working insert/edit/update sql sample for me...

maybe you got something on your hdd for me to share? would help me a lot because i got the strange feeling that iam building a sql injection plugin here ;)

i would need a detailed sample on how i

1. add something to the database with ajax (only loading async.)
2. edit "
3. update "
4. get everything parsed to the right #div

5. how to implement this in a plugin (some sort of jquery db <-> chat)

maybe you have some simple plugin with only a few lines of code where i can get the basics on how to implement this the cot way?
URL shortener: <a href="http://bbm.li/!7AD5C7">http://bbm.li/!7AD5C7</a>
Отредактировано: urlkiller (16.04.2010 21:59, 14 лет назад)
Kilandor
#4 16.04.2010 22:06
You should use the hook for plugin "ajax" then you can use the url plug.php?r=plugcode to send your ajax queries to, this gives you full Cotonti functions. And it only outputs anything you echo out on your plugin hook.
urlkiller
#5 16.04.2010 22:08
ok i figured that out too already.

http://www.cotonti.com/docs/en/plugins/ajax_parts#c784

is there somewhere like an example on this?
URL shortener: <a href="http://bbm.li/!7AD5C7">http://bbm.li/!7AD5C7</a>
Trustmaster
#6 16.04.2010 22:11
Yes, in the markitup plugin, there's markitup.ajax.php
May the Source be with you!
urlkiller
#7 16.04.2010 22:16
ill try this now, thanks.

Added 6 minutes later:

ok ill know stupid question i access the *.ajax.php file in my plugin via the other tutorial and javaS function?
URL shortener: <a href="http://bbm.li/!7AD5C7">http://bbm.li/!7AD5C7</a>
Отредактировано: urlkiller (16.04.2010 22:23, 14 лет назад)
Trustmaster
#8 16.04.2010 22:33
Not really. Just call it like http://example.com/plug.php?r=your_plugin from your JavaScript code (be it Cotonti's, jQuery or whatsoever).
May the Source be with you!
urlkiller
#9 16.04.2010 22:47
hmm... iam doing it the wrong way, i guess!


javascript:
		$(document).ready(function()
    {
      
			$("#submiter").click(function(){
			
					 var message = $('#sendmessage').val();
				   ajaxSend({
					   url: 'plug.php?r=dashboard',
					   method: 'POST',
					   formId: 'myform'
				   })
      
      alert(message);
			$('#sendmessage').val('');
			return false;
			});
   	});


html
<form method="post" action="plug.php?r=dashboard" name="myform" id="myform" class="ajax" onsubmit="return false;">
<textarea class="minieditor" name="sendmessage" id="sendmessage"></textarea>
<input type="hidden" name="action" value="send">
<input type="hidden" name="gid" value="{WAVE_GID}">
<input type="hidden" name="uid" value="{WAVE_UID}">
<input type="hidden" name="cid" value="{WAVE_CID}">

<center><input type="submit" id="submiter" value="test send" style="padding:10px;font-size:18px;"></center>
</form>

*.ajax.php from my plugin
defined('SED_CODE') or die('Wrong URL');


$text = sed_import('sendmessage', 'P', 'TXT');
sed_sendheaders();
echo sed_post_parse(sed_parse($text));
ob_end_flush();



i simply dont get it to work. am i stupid or what?
is there anyway where i can define the output div for the answer send back from the ajax.php part?


(yes there are asome unused variables, iam just testing here so ignore them.)

i simply want a form submit into a pre specified div box. the content should appear right after i pressed submit. any ideas?

Added 52 seconds later:

the ajax part seems to work well, it just dont show up in my "main" page div
URL shortener: <a href="http://bbm.li/!7AD5C7">http://bbm.li/!7AD5C7</a>
ez
#10 16.04.2010 22:59
What is the response off you're agent... (how does that look, Html, json...)

If you are using IE : 1 BIG catch is caching..... !!!!
Always do this:
// disable cache
$.ajaxSetup({ cache: false });

it will make sure that IE does not cache youre response !


1 tip: For posting I am using the Forms plugin..... (a real gem)
http://jquery.malsup.com/form/#ajaxSubmit

Look at the callback to process your returned data

Hope this helps
==- I say: Keep it EZ -==
urlkiller
#11 16.04.2010 23:01
first. No i refuse using this "browser" ...
second. i foun d this article yesterday but iam looking for some easy to convert example with only a few lines of code to get a general view for this technique...

Added 12 minutes later:

doh! divId: 'ajaxDIV',

that little bugger there was part of the problem...
yeah i know! read the fucking manual!
URL shortener: <a href="http://bbm.li/!7AD5C7">http://bbm.li/!7AD5C7</a>
Отредактировано: urlkiller (16.04.2010 23:16, 14 лет назад)
ez
#12 16.04.2010 23:18
IE sucks.. yeah... but a lot off users use it, so keep in mind my tip :)
that one costed me several hours...


You say the ajax works.... so you have got that part working...

So just put the response back in a html element:

http://api.jquery.com/load/

$('#Where').load('ajax/test.html', function() {
alert('Load was performed.');
});

=============
OK (welcome to bug city)
==- I say: Keep it EZ -==
urlkiller
#13 16.04.2010 23:22
trying to build something like google wave without live typing ;)

Added 18 hours 52 minutes later:

@ez

i got 2 versions of my page.
the first one with cool jquery functions
the second one only with text ;) for the IE users (i got under 4% IE users at my site)

(and this isn't some client payed thing...)
URL shortener: <a href="http://bbm.li/!7AD5C7">http://bbm.li/!7AD5C7</a>
Отредактировано: urlkiller (17.04.2010 18:15, 14 лет назад)