Jump to content

AJAX request NOT to file

Recommended Posts

I'm pretty new to Processwire and AJAX so maybe this is not the smartest question (the answer could be easy though).

What I want to achieve is to display images and onclick on an image (which are essentially pages) it should fill the markup below it with specific content of that page's children pages.

By default it should show the first child's content (the newest one). This works fine.

$category = $pages->get("/path/to/parent")->child;
$subcategory = $category->child;
$items = $subcategory->children

foreach ($items as $item) {
echo $item->title; 
// …and more code

I understand that AJAX always requests a URL or file, usually JSON or XML.
Is there a way to not request a specific file but to pass the contents of a PW-API-variable (in this case the children array) to javascript?

Because what I'm trying now is to create an multidimentional array and convert that to a JSON file but that's not easy and I assume, or hope, unnecessary.

Thanks for help!  


Share this post

Link to post
Share on other sites


Share this post

Link to post
Share on other sites

I managed to do an ajax call. On click it sends $_GET-variables to the server, generates markup (text and images) and then lloads it on the page. Everything works as intended.

Now I'm trying to crop the images before loading (->size(450, 250)) but it simply dies when attempting to render images. 

Is that because the AJAX request can only load what's on the server and also rendering the images is just too much?

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...