MyBB Community Forums

Full Version: I broke the AJAX. Lol.
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Let me tell you the tale of how I broke the AJAX on my boards.

I installed the SEO Plugin, then I modified it extensively to get the result I wanted, instead of the standard thread-1.html it now works as /threads/t-1

All is good on that end, I have NO problems with the actual URL's.

What I do have problems with, is the fact that both my Multi-Quote AJAX and Inline Moderation are now broken.

How I did it? I have no clue, but, I do know that I can't find a fix, even though I have tried for weeks.

I completely suck at JavaScript (much less AJAX) so I need someone who actually knows what they are doing to help me.

Any help would be appreciated.

Also, the thing that puzzles me the most, is the fact that when clicking on the Multi-Quote Image, it changes, as it should. But when I click "Quote these posts now" nothing appears in the quick reply box.

And when trying to perform Inline Moderation (posts and threads) the numbers in the Go (#) button increment like they should, but when I go to perform the actual Moderation, the board tells me I did not select any threads/posts.

Quick Edit of Thread Titles works properly, although. And the forum URL's are accessed the same way threads are, the URL's are /forums/f-1.

Please note, simply deactivating the plugin is not and option, I have done extensive amounts of file and template edits to get it to work the way I want, not to mention literally hundreds of other modifications are also tied into the same files and templates.

Please note, the many modifications (outside of the SEO) are not interfering with the AJAX, as everything previously worked before I did this.

I've put too many hours into setting them up this way to strip it all out, I need an actual fix for this issue.

So, please, I've spent weeks pulling my hair out trying to fix this issue, help me! Sad

http://www.evolutionx-productions.com/forums

EDIT: Oh yeah, I also get no errors when trying to perform the actions, via JavaScript pop-up errors or FireBug.
Ryan Ashbrook Wrote:Also, the thing that puzzles me the most, is the fact that when clicking on the Multi-Quote Image, it changes, as it should. But when I click "Quote these posts now" nothing appears in the quick reply box.
would you check This
I had the same problem and that was the fix!
This is a completely different thing that broke the AJAX, it's not a MyBB Bug internally, it was a modification I did.

I don't have that suhosin patch installed.
Sorry, too lazy to read all your post (kinda in a hurry ATM), but IIRC, in thread.js, xmlhttp.php is referenced relatively, so, if your SEO modifications have added "fake paths", your browser can no longer find xmlhttp.php.

I guess the main reason why relative URL is used is because PHP cannot be evaluated in a static JS file (though values can be passed over).
A simple fix would be to open up /jscripts/thread.js and replace references to xmlhttp.php with absolute URLs (ie http://example.com/forum/xmlhttp.php ).

EDIT: Forgot to mention, Firefox blocks AJAX requests which don't originate from the same domain, so a script on http://example.com requesting something from http://www.example.com will be blocked by Firefox. Just something to note.
ZiNga BuRgA Wrote:Sorry, too lazy to read all your post (kinda in a hurry ATM), but IIRC, in thread.js, xmlhttp.php is referenced relatively, so, if your SEO modifications have added "fake paths", your browser can no longer find xmlhttp.php.

I guess the main reason why relative URL is used is because PHP cannot be evaluated in a static JS file (though values can be passed over).
A simple fix would be to open up /jscripts/thread.js and replace references to xmlhttp.php with absolute URLs (ie http://example.com/forum/xmlhttp.php ).

EDIT: Forgot to mention, Firefox blocks AJAX requests which don't originate from the same domain, so a script on http://example.com requesting something from http://www.example.com will be blocked by Firefox. Just something to note.

If that was the issue, then Quick Edit in Threads and Posts wouldn't work either, yet they do.

I've set the calling of xmlhttp.php to /xmlhttp.php when I changed the URL's, because my forum is in my websites root folder.

What makes this problem so weird is that half the file works properly, and half the file doesn't.

Quick Edit, working fine. MultiQuote image switching, working properly. Even the cookie being set is working as it should. It just isn't calling the posts to quote them.
^ Apologies, I should've read your post.

It's a cookie problem - when multi-quoting, the cookie actually isn't set. So when trying to load the quoted messages, this is the request:
GET /xmlhttp.php?action=get_multiquoted&load_all=1&tid=45 HTTP/1.1
Host: www.evolutionx-productions.com
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.2; en-US; rv:1.8.1.4) Gecko/20070515 Firefox/2.0.0.4
Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 7200
Proxy-Connection: keep-alive
Referer: http://www.evolutionx-productions.com/threads/t-45
Cookie: mybb[lastvisit]=1195271123; mybb[lastactive]=1195271810; sid=<REMOVED>; mybb[forumread]=a%3A2%3A%7Bi%3A4%3Bi%3A1195271420%3Bi%3A21%3Bi%3A1195271853%3B%7D; mybb[threadread]=a%3A1%3A%7Bi%3A48%3Bi%3A1195271524%3B%7D; mybbuser=<REMOVED>
If-Modified-Since: Sat, 17 Nov 2007 03:58:34GMT


Adding ";multiquote=135" onto the cookie header allows multi-quoting to work.

As for a fix, I can't really think of one right now...
ZiNga BuRgA Wrote:^ Apologies, I should've read your post.

It's a cookie problem - when multi-quoting, the cookie actually isn't set. So when trying to load the quoted messages, this is the request:
GET /xmlhttp.php?action=get_multiquoted&load_all=1&tid=45 HTTP/1.1
Host: www.evolutionx-productions.com
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.2; en-US; rv:1.8.1.4) Gecko/20070515 Firefox/2.0.0.4
Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 7200
Proxy-Connection: keep-alive
Referer: http://www.evolutionx-productions.com/threads/t-45
Cookie: mybb[lastvisit]=1195271123; mybb[lastactive]=1195271810; sid=<REMOVED>; mybb[forumread]=a%3A2%3A%7Bi%3A4%3Bi%3A1195271420%3Bi%3A21%3Bi%3A1195271853%3B%7D; mybb[threadread]=a%3A1%3A%7Bi%3A48%3Bi%3A1195271524%3B%7D; mybbuser=<REMOVED>
If-Modified-Since: Sat, 17 Nov 2007 03:58:34GMT


Adding ";multiquote=135" onto the cookie header allows multi-quoting to work.

As for a fix, I can't really think of one right now...

Well, at least we know the issue now. Smile
EDIT: change your cookie path to "/" in the AdminCP (I suspect your current path is just "")
ZiNga BuRgA Wrote:EDIT: change your cookie path to "/" in the AdminCP (I suspect your current path is just "")

<_<
>_>

... thanks. Toungue

It was set to that because I built the forums on a localhost and having it set to that was the only way I could have multiple MyBB's on localhost. Toungue

Changing it to / did work, for future reference.