-3

Is it possible to get an PHP class variable with Ajax on load ? My class is called when submit is clicked and I was wondering if there is any way I can get the value in alert box when the loading is done ?

EDIT:

class VacationCalc {
    ......

  function VacationLeft($date) {
    $someValue = (strtotime($date) - strtotime($this->worker->vacationStartDate)) / 86400;
    $rest = $someValue - $this->vacationWithoutPay;
    echo $this->leftDays = number_format($this->worker->daysInyear + ($rest * ($this->worker->vacationDaysInYear / 365.25)) - $this->daysAllreadyDone,1,',',' ');

    }
  }
}

I would like to get the value to an alert box after loading is done.

3
  • 2
    Yeah you can! Glad I could answer your question :) Commented Nov 28, 2012 at 14:01
  • 1
    What do you mean by Class value? Commented Nov 28, 2012 at 14:01
  • You should work on your terminology in order to clarify things and not confuse people. There is nothing like a class value, and a class cannot be run. Some code was nice, too! Commented Nov 28, 2012 at 14:13

1 Answer 1

0

Make the page as any other page you would withou AJAX, but only echoing the desired output.

Than you can call the result via AJAX without a problem.

Sign up to request clarification or add additional context in comments.

3 Comments

How do you make your normal (not AJAX) pages?
I know that part, the page is done..The thing I need to know is how to show the result from a php class in an alert box.
So your question is: "How to call a page via AJAX?". This can help you: stackoverflow.com/questions/1103055/… and this stackoverflow.com/search?q=ajax+class+php

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.