superajax format for UTW fixed

Note: This post is over 2 years old. You may want to check later in this blog to see if there is new information.

My crowning acheivement for the day. Something none of you can see, but it makes my blog so much cooler. I can now edit the tags for each post inline when viewing my blog while logged in as admin (AJAX at work!). It wasn’t working and there wasn’t a solution on the boards, just a bunch of people with the same problem. So I thought I’d just go ahead and try my hand at it.

I edited ultimate-tag-warrior-ajax-js.php to enable async mode in mozilla based browsers, and updated the AJAX function a little bit. It seems to be working well in most browsers but needs more testing. The result is that superajax format adds tags flawlessly in Firefox, which was my main goal.

JavaScript:
  1. function sndReq(action, tag, post, format) {
  2.   var http = createRequestObject();
  3.  
  4.   http.open(‘get’, ‘<?php echo $ajaxurl?>?action=’+action+‘&tag=’+tag+‘&post=’+post+‘&format=’+format,true);
  5.   http.onreadystatechange = function() {
  6.     if(http.readyState == 4){
  7.       var response = http.responseText;
  8.       var update = new Array();
  9.  
  10.       if(response.indexOf(’|’ != -1)) {
  11.         update = response.split(’|’);
  12.         document.getElementById(“tags-“ + update[0]).innerHTML = update[1];
  13.       }
  14.     }
  15.   }
  16.   http.send(null);
  17. }

Basically, I took the handleResponse() function and moved it inside of sndReq(). This had to be done in order to add the “true” at the end of the http.open string that enables async mode. Otherwise the value of http was lost in the background and not passed to handleResponse. It may not be the most elegant solution, but I’m a hack ;-).

But once I got it to update inner.HTML successfully, it still wouldn’t update the screen after deleting. I checked the responses from the AJAX transaction and found that it was returning the string with the deleted tag still in it, even though a refresh of the screen showed it was gone. By commenting out the if statement in lines 545 & 549 of ultimate-tag-warrior-core.php you can bypass the cache and return the string minus the deleted tag.

The two edits combined seem to fix the problems that a lot of people are having with the superajax mode. If anyone wants the files, let me know. I’m inexperienced enough to not know the consequences of bypassing the cache check, so if I’m in trouble, let me know!

The js file also contains edits to make the Keyword Suggest in the Post mode work in Firefox and gecko browsers as mentioned in my other post. I don’t know for sure, but it should help in other browsers as well. I’ll do some testing. I tested in PC IE 6, 7 FF 1.5, NS 7, 8, Moz 1.7. MAC FF 1.5 , Safari 2.04. Opera was the only browser I had trouble with.

» » » » » » » »

Comments are closed

Comments are currently closed on this entry.

Comments are closed.