Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. Multiple evaluatejavascript calls causing javascript Type Error (JQuery)
Qt 6.11 is out! See what's new in the release blog

Multiple evaluatejavascript calls causing javascript Type Error (JQuery)

Scheduled Pinned Locked Moved Mobile and Embedded
3 Posts 1 Posters 2.4k Views 1 Watching
  • 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.
  • G Offline
    G Offline
    gehrig44
    wrote on last edited by
    #1

    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.

    @streamJavascript("$("#on-screen-time").text("" + hourMinAmPmPattern.cap(1) + "");");
    streamJavascript("$("#on-screen-ampm").text("" + hourMinAmPmPattern.cap(2) + "");");

    void AdiTimeManager::streamJavascript(QString javascript)
    {
    QString sJavaScript;
    QTextStream streamJavascript(&sJavaScript);
    streamJavascript << javascript;
    ADIGlobal::sendJavascript(frame, sJavaScript);
    }

    void ADIGlobal::sendJavascript(QWebFrame *frame, QString sJavascript)
    {
    if ( sJavascript != "" )
    {
    if ( Log4Qt::Logger::logger("ADIGlobal") )
    {
    Log4Qt::Logger::logger("ADIGlobal")->debug() << "sendJavascript " << sJavascript;
    }
    frame->evaluateJavaScript(sJavascript);
    }
    }

    08:38:16.135 DEBUG [ADIGlobal] sendJavascript $("#on-screen-time").text("8:38");
    08:38:16.225 DEBUG [ADIGlobal] sendJavascript $("#on-screen-ampm").text("AM");
    08:38:16.225 DEBUG [AdiWebPage] TypeError: Type error
    08:38:16.225 DEBUG [AdiWebPage] 1:@

    1 Reply Last reply
    0
    • G Offline
      G Offline
      gehrig44
      wrote on last edited by
      #2

      Update.

      Apparently, this has nothing to do with multiple calls. All calls are throwing the error, but after every other evaluatejavascript call.

      1 Reply Last reply
      0
      • G Offline
        G Offline
        gehrig44
        wrote on last edited by
        #3

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

        @<form><input type="button" class="ENTER" /></form>@

        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.

        1 Reply Last reply
        0

        • Login

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