QJSEngine evaluates JavaScript encounter error
-
wrote on 12 Mar 2015, 01:32 last edited by
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 ?
-
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.
-
wrote on 13 Mar 2015, 15:56 last edited by
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 ?
-
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 ?
@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:
- Where is the error?
- Tell us, what you have tried so far to fix the mistake?
-
@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:
- Where is the error?
- Tell us, what you have tried so far to fix the mistake?
wrote on 14 Mar 2015, 08:31 last edited by@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.
-
@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?
-
@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?
wrote on 17 Mar 2015, 13:47 last edited by@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/342572119e02Since 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 ?
-
@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.
-
@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.
wrote on 23 Mar 2015, 07:23 last edited by@JKSH someone helped me solve the issue, thanks anyway!
http://www.riverbankcomputing.com/pipermail/pyqt/2015-March/035717.html
1/9