SWI-Prolog / packages-pengines

Pengines: Prolog engines
11 stars 13 forks source link

ask option bug #7

Closed torbjornlager closed 10 years ago

torbjornlager commented 10 years ago

This works:

<html lang="en">
<head>
  <script src="/vendor/jquery/jquery-2.0.3.min.js"></script>
  <script src="/pengine/pengines.js"></script>
  <script type="text/x-prolog">

      p(X) :-
          pengine_rpc('http://pengines.swi-prolog.org', q(X), [
              src_text("q(a). q(b). q(c).")
          ]),
          r(X).

      r(b).
      r(c).

  </script>
  <script>
      var pengine = new Pengine({
          oncreate: handleCreate,
          onsuccess: handleSuccess
      });
      function handleCreate() {
          pengine.ask('p(X)');
      }            
      function handleSuccess() {
          $('#out').html(this.data[0].X);
      }
  </script>
</head>
<body>
    <div id="out"></div>
    <button id="next" onclick="pengine.next()">Next</button>
</body>
</html>

But using the ask option does not work:

<html lang="en">
<head>
  <script src="/vendor/jquery/jquery-2.0.3.min.js"></script>
  <script src="/pengine/pengines.js"></script>
  <script type="text/x-prolog">

      p(X) :-
          pengine_rpc('http://pengines.swi-prolog.org', q(X), [
              src_text("q(a). q(b). q(c).")
          ]),
          r(X).

      r(b).
      r(c).

  </script>
  <script>
      var pengine = new Pengine({
          ask: 'p(X)',
          onsuccess: handleSuccess
      });          
      function handleSuccess() {
          $('#out').html(this.data[0].X);
      }
  </script>
  </style>
</head>
<body>
    <div id="out"></div>
    <button id="next" onclick="pengine.next()">Next</button>
</body>
</html>
torbjornlager commented 10 years ago

Jan fixed this.