ajaxboy / cjax

Lightweight Ajax Framework built in PHP with no foot-print. Allows you to build ajax functionality with a single line of code & do so much more, right from the back-end!
http://cjax.sourceforge.net/
66 stars 27 forks source link

Demo/ Creating Plugins(+Javascript API +PHP API) Docs broken #20

Open ajaxboy opened 8 years ago

ajaxboy commented 8 years ago

The documentation for Demo "Creating Plugins(+Javascript API +PHP API)" appears to be broken and only shows partial information, while there is much more info than the one that appears.

Link: http://cjax.sourceforge.net/examples/plugins.php

HallofFamer commented 8 years ago

@ajaxboy

I was able to fix this problem in CJAX 6.0 Beta 1(will be available soon). The issue is with the method CoreEvents::jsCode(), specifically this line:

$data =  "<script>". highlight_string("\n" . $data ."\n");

As you can see, the code wraps data inside script tag, but it only adds an opening script tag, without a closing script tag. For this reason, calling method jsCode() will render the rest of lines to be javascript, effectively messing up the HTML of a page.

To fix this issue, simply change this line to:

 $data =  "<script>". highlight_string("\n" . $data ."\n")."</script>"; 

And the creating plugins page should appear normally, as it shows up on CJAX 6.0 Beta's demo site: http://mysidiarpg.com/site/cjax/cjax600b1/examples/plugins.php

ajaxboy commented 8 years ago

Very nice. Thanks. That ought do it

HallofFamer commented 8 years ago

You are welcome, I will make a push request for CJAX master branch regarding this change.