Jump to content

New to PW - AJAX for Dummies


Kurbel
 Share

Recommended Posts

Hi Guys,

I'm new to ProcessWire and really like it. I developed a few Wordpress Templates for Customers and Friends, finally got feed up with it for sites that are not blogs and decided I need something more flexible but not more complicated.

So far PW does seem to fit the bill quite nicely :-)

However I've run into a problem that I can't get my head around and by now I'm not sure if it's am Issue with my jQuery or my PW or something in between. 

Consider this Code:

jQuery:

$(document).ready(function() {
    $("#button").click(function(){
          $.ajax({
              type: "POST",
              url: "news-fetcher/",
              data: { start: 1, end: 5 },
              success: function(data,status){
                  alert(data);
            }
        });
    });
});
 

news-fetcher, this template:

<?php
    $start = $input->post->start;
    $end = $input->post->end;
    echo "Start:  $start
            End: $end";
?>
 

For some reason - that I can't figure out for the live of me - both input variables end up empty.

Things I checked so far:

- URL returns a 200 OK status code

- news-fetcher.php is a template

- jQuery is loaded and working

- response get's returned, alert is triggered

- custom post request (Postman Chrome extension) returns the same result

I'm sure it's something blatantly obvious that's awry here, but for whatever reason I'm entirely unable to find it. After staring at this problem for quite a few hours, every input would be very much appreciated!

Cheers,

Kurbel

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...