Ajax call Access Denied.

Permalink
I have an click event for ajax request

My PHP file is in theme directory .
Inside I have
<?php  
defined('C5_EXECUTE') or die("Access Denied."); 
if(isset($_POST["page"]) && !empty($_POST["page"]))
{ 
    $data = ($_POST["href"]);
    echo $data.' Вот что!!!';
}
?>


and I have also JS
<script>
  $('#link').click(function(event){
    event.preventDefault();
      var href = $(this).attr('href');
      var dataString = 'href=' + href + '&page=fileset';
      $.ajax({
            type: "POST",
            url: "<?php echo $this->getThemePath()?>/test_ajax.php",
            data: dataString,
            cache: false,
            success: function(response)
            {
                $("#signup_status").html(response);
            }
        });


So what I expect to get is #test

But I get Access Denied.

As I think is because of this line defined('C5_EXECUTE') or die("Access Denied.");

But if i will not use it I can't use any page_list or fileset of concrete5

There is any solution???

sergio11ofpp
 
JohntheFish replied on at Permalink Reply
JohntheFish
This may be because you are trying to ajax to something that is not a tool or an action.
sergio11ofpp replied on at Permalink Reply
sergio11ofpp
Yeah I just realized that.
So I created a tool like 'ajax.php'
after I got
$tools_url = Loader::helper('concrete/urls')->getToolsURL('gallery');


and In JS
$.ajax({
            type: "POST",
            url: "<?php echo $tools_url ?>",
            data: dataString,


Now I am thinking what to pass so based on link pressed show different filset)) I am doing gallery(
JohntheFish replied on at Permalink Best Answer Reply
JohntheFish
chris123uk replied on at Permalink Reply
chris123uk
hi how can i get back the center of a subpage of the site in an ajax call? i cant think of a way of coding a tool to do this.
i dont want to use an addon as that would be cheating. would prefer to learn. i have read all the documentation available so thought i would ask here. thanks
JohntheFish replied on at Permalink Reply
JohntheFish
Shame you don't want a MP package. The off-the-shelf solution is Universal Content Puller + Blocks By AJAX.

http://www.concrete5.org/marketplace/addons/universal-content-pulle...
http://www.concrete5.org/marketplace/addons/blocks-by-ajax/...
chris123uk replied on at Permalink Reply
chris123uk
yes i know of them :)

but what i do is build themes day in day out here at work and what i would like is to have all this ajax stuff in my theme to pull in each sub page centre when a user clicks nav link.

Using HTML5 popstate for google so it still indexes the pages.

So i would like this to be self contained within my theme in an include. so next time i make a theme i can just copy theme directory and all my ajax will just work.

I don't care about logged in users I can just have a condition that targets logged out users before doing any sub page pulls through ajax.

My problem seems to be that concrete5 wants me to use a tools file but what i want to do is just pull a section of another page with ajax but i get a access denied error in console.

so i have looked into how i can pull the page into the tools file then pass back to the ajax caller.

I think this has something to do with making it:
http://stackoverflow.com/questions/18430725/concrete5-load-area-wit...

But i don't want to pull a single block back. I want to pull back the whole page and select the middle wrapper tag. can any one see how that is possible?


without the tools file would be best.
I have not checked if i get the access denied error when logged out yet so that would be the next step if i do i might have to find a way of sending the security token over in the ajax call??
chris123uk replied on at Permalink Reply
chris123uk
ah crap it works without access denied all along lol

using:

$.get( "http://surgemarketingsolutions.co.uk/", function( data ) {
$( "#result" ).html( data );
alert( "Load was performed." );
});

so i can ajax full pages! was originally getting the access denied error when loading a php script in my theme directory that had the defined('c5_execute') in it.

Am so scatty... Any way on to building my html5 pop state ajax navigation! am following this tutorial if anyones interested:http://css-tricks.com/rethinking-dynamic-page-replacing-content/...