Results 1 to 2 of 2

Thread: Multiple evaluatejavascript calls causing javascript Type Error (JQuery)

  1. #1
    Join Date
    May 2012
    Posts
    2
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default Re: Multiple evaluatejavascript calls causing javascript Type Error (JQuery)

    If I have my application execute back to back evalutatejavascript calls using the same frame object, the second call always throws a javascript TypeError: Type error message.

    If I combine all the javascript/jquery into one evaluatejavascript call, then it works fine. Which is what I am going to do. But, the issue has me concerned since evaluatejavascript is used quite a bit in our application.

    Qt Code:
    1. streamJavascript("$(\"#on-screen-time\").text(\"" + hourMinAmPmPattern.cap(1) + "\");");
    2. streamJavascript("$(\"#on-screen-ampm\").text(\"" + hourMinAmPmPattern.cap(2) + "\");");
    3.  
    4. void AdiTimeManager::streamJavascript(QString javascript)
    5. {
    6. QString sJavaScript;
    7. QTextStream streamJavascript(&sJavaScript);
    8. streamJavascript << javascript;
    9. ADIGlobal::sendJavascript(frame, sJavaScript);
    10. }
    11.  
    12.  
    13. void ADIGlobal::sendJavascript(QWebFrame *frame, QString sJavascript)
    14. {
    15. if ( sJavascript != "" )
    16. {
    17. if ( Log4Qt::Logger::logger("ADIGlobal") )
    18. {
    19. Log4Qt::Logger::logger("ADIGlobal")->debug() << "sendJavascript " << sJavascript;
    20. }
    21. frame->evaluateJavaScript(sJavascript);
    22. }
    23. }
    24.  
    25.  
    26.  
    27. 08:38:16.135 DEBUG [ADIGlobal] sendJavascript $("#on-screen-time").text("8:38");
    28. 08:38:16.225 DEBUG [ADIGlobal] sendJavascript $("#on-screen-ampm").text("AM");
    29. 08:38:16.225 DEBUG [AdiWebPage] TypeError: Type error
    30. 08:38:16.225 DEBUG [AdiWebPage] 1:
    To copy to clipboard, switch view to plain text mode 


    Added after 57 minutes:


    Update.

    Apparently, this has nothing to do with multiple calls. All calls are throwing the error, but after every other evaluatejavascript call.
    Last edited by gehrig44; 11th May 2012 at 14:49.

  2. #2
    Join Date
    May 2012
    Posts
    2
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default Re: Multiple evaluatejavascript calls causing javascript Type Error (JQuery)

    I found a work around.. however I dont have any idea why it works. There is a form element further down the page:

    Qt Code:
    1. <form><input type="button" style="display:none;" class="ENTER" /></form>
    To copy to clipboard, switch view to plain text mode 

    When changing the input type to "text" it everything works fine. Luckily, the input type doesn't matter for me.

    I really have no idea why this would matter.

Similar Threads

  1. [MinGW] Multiple calls to qmake
    By Potch in forum Installation and Deployment
    Replies: 2
    Last Post: 21st December 2013, 07:30
  2. Replies: 2
    Last Post: 19th October 2011, 09:30
  3. multiple QTimer::singleShot() calls?
    By mattc in forum Qt Programming
    Replies: 1
    Last Post: 27th July 2009, 19:22
  4. processEvents causing multiple events
    By jefferai in forum Qt Programming
    Replies: 1
    Last Post: 30th June 2008, 07:08

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.