Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QJSEngine evaluates JavaScript encounter error

QJSEngine evaluates JavaScript encounter error

Scheduled Pinned Locked Moved General and Desktop
9 Posts 2 Posters 2.2k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    redstoneleo
    wrote on 12 Mar 2015, 01:32 last edited by
    #1

    I don't have much knowledge about JavaScript ,I am using QJSEngine to evaluate this js code snippet here , then error occurs : SyntaxError: Expected token `,' https://bpaste.net/show/be6620300fef anyone can help ?

    1 Reply Last reply
    0
    • J Offline
      J Offline
      JKSH
      Moderators
      wrote on 12 Mar 2015, 02:28 last edited by JKSH 3 Dec 2015, 02:30
      #2

      Hi,

      Run your JavaScript code through an error checker: http://www.javascriptlint.com/online_lint.php It will show you where the error is.

      By the way, it's probably a bad idea to embed such a large piece of JavaScript code inside Python code. Instead, put the JavaScript code inside a separate file, and get your Python code to read the file into a string.

      Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

      1 Reply Last reply
      0
      • R Offline
        R Offline
        redstoneleo
        wrote on 13 Mar 2015, 15:56 last edited by
        #3

        thanks, although it can show where the error is,but I still found it hard to correct the mistake due to a lack of experience in Js, can you give a help ?

        J 1 Reply Last reply 14 Mar 2015, 01:35
        0
        • R redstoneleo
          13 Mar 2015, 15:56

          thanks, although it can show where the error is,but I still found it hard to correct the mistake due to a lack of experience in Js, can you give a help ?

          J Offline
          J Offline
          JKSH
          Moderators
          wrote on 14 Mar 2015, 01:35 last edited by
          #4

          @redstoneleo said:

          thanks, although it can show where the error is,but I still found it hard to correct the mistake due to a lack of experience in Js, can you give a help ?

          I'd be happy to help, but I'd like you to put in some effort yourself first:

          1. Where is the error?
          2. Tell us, what you have tried so far to fix the mistake?

          Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

          R 1 Reply Last reply 14 Mar 2015, 08:31
          0
          • J JKSH
            14 Mar 2015, 01:35

            @redstoneleo said:

            thanks, although it can show where the error is,but I still found it hard to correct the mistake due to a lack of experience in Js, can you give a help ?

            I'd be happy to help, but I'd like you to put in some effort yourself first:

            1. Where is the error?
            2. Tell us, what you have tried so far to fix the mistake?
            R Offline
            R Offline
            redstoneleo
            wrote on 14 Mar 2015, 08:31 last edited by
            #5

            @JKSH
            ok, I turn the code a little bit clear to understand by replacing _, _l, __l with letter i,a,b and so on .

            this is the processed code,

            https://bpaste.net/show/f60deff86d2b

            I am not able to correct the mistake in it due to a lack of experience in Js, but I found the js code is not that hard to rewrite with Python ,so I turn the js code to the corresponding Python code, this is the code

            https://bpaste.net/show/2f9b2fe5a333

            I hope someone can help me correct the mistake in the js code so I don't need to rewrite it with Python , and so that I can run it and get result directly via QJSEngine.

            1 Reply Last reply
            0
            • J Offline
              J Offline
              JKSH
              Moderators
              wrote on 14 Mar 2015, 14:46 last edited by
              #6

              @redstoneleo Actually, there is no mistake in the JavaScript code.

              I think you need to put the JavaScript code inside a file, and make your Python code read the file. Don't embed the JavaScript code directly in your Python code.

              Anyway, I'm curious: Where did you get this code from?

              Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

              R 1 Reply Last reply 17 Mar 2015, 13:47
              0
              • J JKSH
                14 Mar 2015, 14:46

                @redstoneleo Actually, there is no mistake in the JavaScript code.

                I think you need to put the JavaScript code inside a file, and make your Python code read the file. Don't embed the JavaScript code directly in your Python code.

                Anyway, I'm curious: Where did you get this code from?

                R Offline
                R Offline
                redstoneleo
                wrote on 17 Mar 2015, 13:47 last edited by
                #7

                @JKSH In fact ,This is a snippet from a JavaScript file loaded by a site,the full code of the JavaScript file is here
                https://bpaste.net/show/342572119e02

                Since a script is provided to the engine in the form of a string, so I think it doesn't bother here to put the JavaScript code inside a file or not.

                "there is no mistake in the JavaScript code", then which caused the error here ?

                1 Reply Last reply
                0
                • J Offline
                  J Offline
                  JKSH
                  Moderators
                  wrote on 17 Mar 2015, 14:26 last edited by
                  #8

                  @redstoneleo said:

                  Since a script is provided to the engine in the form of a string, so I think it doesn't bother here to put the JavaScript code inside a file or not.

                  I suggest you try it anyway.

                  "there is no mistake in the JavaScript code", then which caused the error here ?

                  I don't know. It works with my C++ QJSEngine.

                  Note that this JavaScript code generates more JavaScript code which finally generates HTML code.

                  Anyway, try the file first.

                  Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

                  R 1 Reply Last reply 23 Mar 2015, 07:23
                  0
                  • J JKSH
                    17 Mar 2015, 14:26

                    @redstoneleo said:

                    Since a script is provided to the engine in the form of a string, so I think it doesn't bother here to put the JavaScript code inside a file or not.

                    I suggest you try it anyway.

                    "there is no mistake in the JavaScript code", then which caused the error here ?

                    I don't know. It works with my C++ QJSEngine.

                    Note that this JavaScript code generates more JavaScript code which finally generates HTML code.

                    Anyway, try the file first.

                    R Offline
                    R Offline
                    redstoneleo
                    wrote on 23 Mar 2015, 07:23 last edited by
                    #9

                    @JKSH someone helped me solve the issue, thanks anyway!
                    http://www.riverbankcomputing.com/pipermail/pyqt/2015-March/035717.html

                    1 Reply Last reply
                    0

                    1/9

                    12 Mar 2015, 01:32

                    • Login

                    • Login or register to search.
                    1 out of 9
                    • First post
                      1/9
                      Last post
                    0
                    • Categories
                    • Recent
                    • Tags
                    • Popular
                    • Users
                    • Groups
                    • Search
                    • Get Qt Extensions
                    • Unsolved