The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
|||
|
|||
Accessing $vbulletin on a page called via AJAX
Hello,
I want to add some ajax functionality to the UI that calls a custom php script and accesses $vbulletin and data managers to do different things depending on which button a user pushes from the UI. The problem I'm having is that $vbulletin and other vBulletin related variables are not in scope on the php page the AJAX request hits, even when I include global.php on it. Can anyone tell me what I would have to do to give php pages accessed via AJAX requests access to $vbulletin, etc.? For starters, I would like the file, say myAjaxCalls.php, to do something as simple as this when the JavaScript hits it via AJAX and displays what the PHP page outputs: PHP Code:
PHP Code:
|
#2
|
|||
|
|||
I'm not an expert on ajax or anything, but I don't see anything wrong with your code. It works with a regular (not ajax) request. You have your script in the same directory as global.php, right?
Does an ajax request automatically include cookies? You'd need either the cookies or the security token for vb to recognize you as logged in. Maybe try using something like the FireFox addon "Tamper Data" to see what's being passed back and forth when the request is made. |
#3
|
|||
|
|||
Bad syntax. Try:
also put this in your code: ini_set('display_errors', '1');Then your syntax errors should show |
#4
|
|||
|
|||
Good call - I agree, I forgot that by default the errors aren't displayed (I put display_errors = On in my php.ini long ago...Edit: on my test forum - you don't want to do that on your live forum). But just for the record, there's nothing wrong with the syntax in the OP.
|
#5
|
|||
|
|||
I always use require() or require_once(). I thought include and require had the same syntax.
@Chunky Monkey, is the "Hello " coming through? |
#6
|
|||
|
|||
Quote:
In the past "include 'filename.php'" always seemed to work, so I'm not entirely sure why it doesn't here but this did. Thanks again, Chunky Monkey |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|