changing forwarding method from PHP to JS