1

Topic: Could not execute AJAX call, server didn't return valid a xml

Hi,

I install the new spellchecker plugin but when I click on the spellchecker button, i have this error :

"Could not execute AJAX call,  server didn't return valid a xml"

I have installed PHP, pspell and the spellchecker is working when i'm doing something like this in a php testing page.

$pspell_link = pspell_new("en");

if (pspell_check($pspell_link, "testt")) 
{
echo "This is a valid spelling";
} 
else 
{
echo "Sorry, wrong spelling";
}

Any idea where is the problem ?

Thanks,

2

Re: Could not execute AJAX call, server didn't return valid a xml

Edit tinyspell.php and modify the following code block; (lines 34-40)

    $cmd = @sanitize($_POST['cmd']);
    $lang = @sanitize($_POST['lang'], "strict");
    $mode = @sanitize($_POST['mode'], "strict");
    $spelling = @sanitize($_POST['spelling'], "strict");
    $jargon = @sanitize($_POST['jargon'], "strict");
    $encoding = @sanitize($_POST['encoding'], "strict");
    $sg = @sanitize($_POST['sg'], "bool");

Note the @s before the sanitize() function.

The javascript never actually sends any of those parameters so the script craps out and sends back XML full of php "unidentified index" errors. The @s suppress the errors and the spell checker seems to behave as expected.

3

Re: Could not execute AJAX call, server didn't return valid a xml

this didn't resolve the problem... sad

www.m4u.eu the easiest way to send your sms

4

Re: Could not execute AJAX call, server didn't return valid a xml

It didn't solve my problem either!! I am getting the same error

5

Re: Could not execute AJAX call, server didn't return valid a xml

We are looking into upgrading the spellchecker very soon, should take care of some of these issues.

What you could try is to add

error_reporting(E_ALL ^ E_NOTICE);

at the top of the tinyspell.php script.

Afraithe
TinyMCE Developer
Moxiecode Systems

6

Re: Could not execute AJAX call, server didn't return valid a xml

I have the same problem.
When I call the tinyspell.php file, it gives me:

This application has requested the Runtime to terminate it in an unusual way.  Please contact the application's support team for more information. Unhandled  Error: C:\Program Files\Aspell\dict/en-only.rws: The file "C:\Program  Files\Aspell\data/iso8859-1.dat" is not in the proper format.

Any ideas?

7

Re: Could not execute AJAX call, server didn't return valid a xml

I have a proposal for another AJAX/Google plugin: rather than double posting, see this other thread on the TinyMCE forums.

8

Re: Could not execute AJAX call, server didn't return valid a xml

Hi Afraithe,

I'm having the same problem as above when trying to use the Google web service on a test system running Win XP Pro, IIS 5.1 and PHP 4.4.1. However, using the same version of TinyMCE and Spellchecker (2.0.6.1 & 1.0.1 respectively) on my Server running Windows 2003 Server, IIS 6 and PHP 4.3.11 it all seems to work in both IE and Firefox.

I turned on PHP error reporting on my test system as you suggested, and this is what appeared in my PHP error log;

PHP Notice:  Use of undefined constant PSPELL_FAST - assumed 'PSPELL_FAST' in X:\spellchecker\config.php on line 14
PHP Notice:  Undefined index:  mode in X:\spellchecker\tinyspell.php on line 36
PHP Notice:  Undefined index:  spelling in X:\spellchecker\tinyspell.php on line 37
PHP Notice:  Undefined index:  jargon in X:\spellchecker\tinyspell.php on line 38
PHP Notice:  Undefined index:  encoding in X:\spellchecker\tinyspell.php on line 39
PHP Notice:  Undefined index:  sg in X:\spellchecker\tinyspell.php on line 40
PHP Notice:  Undefined property:  errorMsg in X:\spellchecker\tinyspell.php on line 86

After applying the changes Atlas suggested above I get this in my PHP error logs;

PHP Notice:  Use of undefined constant PSPELL_FAST - assumed 'PSPELL_FAST' in X:\spellchecker\config.php on line 14
PHP Notice:  Undefined property:  errorMsg in X:\spellchecker\tinyspell.php on line 85

9

Re: Could not execute AJAX call, server didn't return valid a xml

Suggestion by Atlas and Afraithe seems can only solve the problem when using internal PHP Version and Google web service.

10

Re: Could not execute AJAX call, server didn't return valid a xml

Thanks for the suggestion mickey9801. I've tried using both the Google web service as well as the internal PHP version and the only difference I can see is that when using the internal PHP version the "Could not execute AJAX call, server didn't return valid a XML." error comes up instantly, where with Google it takes a good 5 seconds or so. I assume this is just the connection delay of connecting to Google, and there are no different errors/warnings in my PHP error log.

I searched through the TinyMCE spellchecker code, and the only place I could see the aove error was in editor_plugin.js in this ajax response function;

,_ajaxResponse:function(xml){var el=xml?xml.documentElement:null;var inst=tinyMCE.selectedInstance,self=TinyMCE_SpellCheckerPlugin;var cmd=el?el.getAttribute("cmd"):null,err,id=el?el.getAttribute("id"):null;if(id)inst=tinyMCE.getInstanceById(id.substring(0,id.indexOf('|')));self._displayUI(inst);if(cmd=="suggest"&&id!=inst.editorId+"|"+self._counter)return;if(!el){inst.spellcheckerOn=false;tinyMCE.switchClass(inst.editorId+'_spellchecker','mceMenuButton');alert("Could not execute AJAX call, server didn't return valid a XML.");return;}

Totally stumped as to why my test system doesn't work, but my server does...

Last edited by brashquido (2006-06-16 02:36:32)

11

Re: Could not execute AJAX call, server didn't return valid a xml

As I'm able to consistantly reproduce this issue I've logged it as a bug report on sourceforge;

http://sourceforge.net/tracker/index.ph … tid=635682

12

Re: Could not execute AJAX call, server didn't return valid a xml

First and foremost, TinyMCE is fantastic!  Thank you all very much for the great work!

Here's some debug info that may help ya:

Throw an alert in _sendAjax and _ajaxResponse ...  (/plugins/spellchecker/editor_plugin_src.js)

You will see that the first 3 times through the XML obj is null and throws the  "error." 

The fourth time around the  [Object XMLDocument] is finally available to the function...  Ideas?

CODE SNIPPITS:

//_sendAjax func
x.onreadystatechange = function() {
    if (x.readyState == 4)
    //Find me
        alert(x.responseText);  //just what are we getting back??
    f(x.responseXML);
    };
}
//-------
_ajaxResponse : function(xml) {
    //Find me
    alert(xml);
    var el = xml ? xml.documentElement : null;

13

Re: Could not execute AJAX call, server didn't return valid a xml

For the people still having trouble;

Can you run the test script posted by cjoathon?

If you can run that, then you should be able to use the spellchecker.

Edit: Assuming you want to use PHPs internal pspell module, that is...

Last edited by Atlas (2006-06-23 09:05:36)

14

Re: Could not execute AJAX call, server didn't return valid a xml

I have tried cjoathon's code, but pspell still does not work. Firefox just fails to pick up mistakes, and IE still throws up the "Could not execute AJAX call, server didn't return valid a XML." error.

15

Re: Could not execute AJAX call, server didn't return valid a xml

brashquido wrote:

I have tried cjoathon's code, but pspell still does not work.

If cjoathon's code didn't work, then you don't have pspell installed and the spell checker is never going to work until you install/enable it.

That's not a bug...

16

Re: Could not execute AJAX call, server didn't return valid a xml

Any progress yet on a Google version that works?

17

Re: Could not execute AJAX call, server didn't return valid a xml

Atlas wrote:

If cjoathon's code didn't work, then you don't have pspell installed and the spell checker is never going to work until you install/enable it.

That's not a bug...

Actually, according to phpinfo() PSpell Support is enabled on my system, I just got names mixed up (confused you for cjoathon). I'll try using Spellchecker outside of Drupal and see how I go...

According to the notes at http://us2.php.net/manual/en/ref.pspell.php you actually need to install aspell 0.50 or newer for Win32 and copy aspell-15.dll into System32 (which I have done, along with installing English dictionary files). Using aspell from the command line works, using the spellchecker plugin does not and still throws up that "Could not execute AJAX call, server didn't return valid a XML."

Last edited by brashquido (2006-06-27 08:43:49)

18

Re: Could not execute AJAX call, server didn't return valid a xml

mrrena wrote:

Any progress yet on a Google version that works?

I beleive I read that Google have recently shifted their service to an SSL based delivery. I think there is a patch out to fix it, but not sure what stage it is at...

19

Re: Could not execute AJAX call, server didn't return valid a xml

Thanks for the reply, Brashquido. Actually, though, that part shouldn't be hard to update: I would think it would just be a matter of adding an "s" to "http" and we should be good to go, unless I am overlooking something. Actually, I already did that on my installations (non-TinyMCE installations, that is) of Googiespell and they work just fine now.

My problem was that I never could get the TinyMCE Google spellcheck plugin to work from the very beginning and I got the impression that others were having this same difficulty, though I think that impression mainly comes from another thread, as I'm subscribed to two that are concerned with this topic, as well as the fact that on the full feature example page, one can type in all kinds of horrendous misspellings and it reports "no spelling errors found." That was really what I was asking about more than anything. For some reason, the spellcheck plugin never did work for me no matter how much I hacked and configured and fussed and fretted. It would seem to be sending an Ajax call to Google, but in the end it would only return an error. And I don't have an Aspell of Pspell installation--from what I understand (though I could be wrong) one has to have SSH access in order to configure that and my hosting package does not offer that. I'm just looking for something simple that works "straight out of the box" on any server anywhere.

20

Re: Could not execute AJAX call, server didn't return valid a xml

It just occurred to me that the reason the full feature example isn't working is because it has not yet been configured to access the secure server that Google is now using. But that of course doesn't get me any closer to getting a local installation working. sad

21

Re: Could not execute AJAX call, server didn't return valid a xml

Check the plugin list on the TinyMCE Sourceforge website.

http://sourceforge.net/tracker/?group_i … tid=738747

yuriy_kramar submitted a fixed version, it should work if you have CURL installed on your hosting solution.

Afraithe
TinyMCE Developer
Moxiecode Systems

22

Re: Could not execute AJAX call, server didn't return valid a xml

I tried your suggestion with high hopes, Afraithe, knowing that I am Curl enabled. However, my results were the same: "Could not execute AJAX call,  server didn't return valid a xml." My guess is there must be something in the plug-in code itself that is misconfigured: Googiespell, using Clem's PHP hack (w/Curl) works just fine. Also, the error reporting you mention above is included by default in this version, though no errors were reported other than the JavaScript alert. Any ideas why we can't make the connection? This one is supposed to have been updated for Google's secure servers.

23

Re: Could not execute AJAX call, server didn't return valid a xml

Hello everyone,

It's 1am, and I've just spent 20 minutes fixing the spell checker to work with Google and both English and French languages for a site of time.  All the problems stem from PHP Notices which are generated throughout the code - these cause problems in that they appear before the XML response and prevent proper interpretation of the XML return.  It's quite easy to fix - in an ideal situation you wouldn't have assumptions in your code that allowed notices to occur, especially in something that generates XML.

Anyway, this is now in a 'works for me' state - you're welcome to try out the replacement code on your own installations.

All of the modifications are in tinyspell.php.

First, replace the sanitize checks, starting with $_POST['mode'] with the following:

    if (isset($_POST['mode'])) {
        $mode = sanitize($_POST['mode'], "strict");
    }
    if (isset($_POST['spelling'])) {
        $spelling = sanitize($_POST['spelling'], "strict");
    }
    if (isset($_POST['jargon'])) {
        $jargon = sanitize($_POST['jargon'], "strict");
    }
    if (isset($_POST['encoding'])) {
        $encoding = sanitize($_POST['encoding'], "strict");
    }
    if (isset($_POST['sg'])) {
        $sg = sanitize($_POST['sg'], "bool");
    }

Next, on line 97, replace the IF statement with this:

    if (!isset($tinyspell->errorMsg) || count($tinyspell->errorMsg) == 0) {

And finally, for completeness (though since you have hopefully just fixed the XML error this shouldn't be a problem), on line 135 your new code is

            echo '<res id="' . $id . '" cmd="'. $cmd .'" error="true" msg="'. @implode(" ", $tinyspell->errorMsg) .'" />';

I hope this helps someone - I registered specially to post this!

24

Re: Could not execute AJAX call, server didn't return valid a xml

I just realised that all that makes very little sense as the line numbers are wrong...  Hopefully you can work it out.  Also, another thing I forgot is that you need to be using the CURL plugin linked to above, and also edit tinyspell.php to remove all the calls to dbg() - this was obviously a mistake left in by the author...

25

Re: Could not execute AJAX call, server didn't return valid a xml

You, my friend, are worth your weight in gold! I have been all over this plug-in trying to get it to work, though I confess I did not really know what I was doing. I finally gave up on ever getting it to work--and then you came along! big_smile

To make it easier for everybody so nobody else has to fuss with line numbers and the like, I have uploaded a copy of sbirtwistle's modified "tinyspell.php" as a .zip--and it is a truly tiny .zip file indeed: approximately 1.4 KB. wink Just download at http://silenceisdefeat.com/~mrrena/tinyspell.zip, unzip, and upload over your current "tinyspell.php" file.

You saved the day, sbirtwistle!

Last edited by mrrena (2008-12-23 06:44:43)