Skip to content
This repository has been archived by the owner on May 30, 2023. It is now read-only.

catching the jQuery parseXML exception #11208

Closed
repinel opened this issue Apr 4, 2013 · 7 comments
Closed

catching the jQuery parseXML exception #11208

repinel opened this issue Apr 4, 2013 · 7 comments
Labels

Comments

@repinel
Copy link

repinel commented Apr 4, 2013

I'm not sure if it's an issue, but shouldn't the following code throw an exception and reach the catch block?

try {
jQuery.parseXML('foo');
} catch(e) {
console.log(e.message);
}

@JamesMGreene
Copy link
Collaborator

  • What OS? What version?
  • What version of PhantomJS?
  • What version of jQuery?
  • What is the context of this script?
    • An existing script on an existing page?
    • A PhantomJS-injected script onto an existing page?
    • A page.evaluate call to an existing page?
    • Run in the PhantomJS outer context?
    • REPL mode?

@JamesMGreene
Copy link
Collaborator

(But the expectation would be: "yes, it should".)

@repinel
Copy link
Author

repinel commented Apr 5, 2013

Actually, my example with just 'foo' is working properly. I am having problems with something like '<foo></foogoo>'.

  • What OS? What version?
    Ubuntu 12.10 AMD64 and Windows 7 64-bit
  • What version of PhantomJS?
    PhantomJS 1.9.0
  • What version of jQuery?
    Happened with 1.6.1 and 1.8.2
  • What is the context of this script?
    • An existing script on an existing page?
    • A PhantomJS-injected script onto an existing page?
    • A page.evaluate call to an existing page?
    • Run in the PhantomJS outer context?
    • REPL mode?
console.log('Started');

var page = require('webpage').create();

page.onConsoleMessage = function(msg) {
  console.log(msg);
};

page.includeJs("http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js", function() {
    console.log('Loaded jQuery');
    page.evaluate(function() {
        try {
          console.log('Parsing XML');
          var doc = jQuery.parseXML('<foo></foogoo>');
          console.log('XML is valid? ' + (doc.length == 1));
        } catch(e) {
          console.log(e.message);
        }
    });
    phantom.exit();
});

The same JavaScript code is working as expected on jsFiddle http://jsfiddle.net/u4Amm/

@mars
Copy link

mars commented Feb 14, 2014

Currently experiencing this issue too.

  • What OS? What version? Mac OS X 10.9.1
  • What version of PhantomJS? PhantomJS 1.9.2
  • What version of jQuery? jQuery 1.10.1
  • What is the context of this script? An existing script on an existing page: running a Jasmine spec suite

@ghost
Copy link

ghost commented Jul 3, 2015

I'm also experiencing this issue. Is there any workaround for this?

  • What OS? What version? Linux Mint 16
  • What version of PhantomJS? PhantomJS 1.9.8
  • What version of jQuery? jQuery 2.1.4
  • What is the context of this script? An existing script on an existing page: running a Jasmine spec suite

@LeMoussel
Copy link

Code working properly

  • What OS? What version? Windows 7
  • What version of PhantomJS? PhantomJS 2.0.0
  • What version of jQuery? jQuery 2.1.4
  • What is the context of this script? An existing script

Result:

Started
Loaded jQuery
Parsing XML
XML is valid? false`

@ghost ghost removed old.Module-WebPage labels Dec 19, 2017
@stale stale bot added the stale label Dec 26, 2019
@stale
Copy link

stale bot commented Dec 29, 2019

Due to our very limited maintenance capacity (see #14541 for more details), we need to prioritize our development focus on other tasks. Therefore, this issue will be automatically closed. In the future, if we see the need to attend to this issue again, then it will be reopened. Thank you for your contribution!

@stale stale bot closed this as completed Dec 29, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

4 participants