Giter Site home page Giter Site logo

Comments (11)

feuzeu avatar feuzeu commented on August 19, 2024 1

You're welcome.
Happy coding with Jaxon!

from jaxon-core.

feuzeu avatar feuzeu commented on August 19, 2024

Hi,
I think this error means that the Jaxon javascript library is unable to parse the response your app sent back.
This often happens when the app outputs additional debug data that is added to the Jaxon response.

Try to use the dev tools of your browser to see the response your app sends back.

from jaxon-core.

lxaraujo avatar lxaraujo commented on August 19, 2024

thank's for your response, but unfortunately the only thing that it shows is the syntax error message. I guessed that was my xdbug that was causing this but I tested in other browser and same thing came up. I am getting frustrated because Xajax is very simple to use and I am trying Jaxon for the same reason but this issue is driving me crazy. I am resourceless. I think the Jaxon website should have more complete examples about how to use this library, not only fragments of code, it seems a very good library. I learned Xajax almost only by examples. If they can provide a complete file whit HTML and PHP from the beginning would be a great help. I will keep diging. thanks again for your attention.

from jaxon-core.

feuzeu avatar feuzeu commented on August 19, 2024

Hi,
If the issue comes from your app as I guessed, using a different browser will not change anything.

If you are using Chrome or Firefox on Linux or Windows, press Ctrl-Maj-i to show the dev tools window, then go to the Network tab. You'll see your HTTP requests there. If the tab is empty, reload the page or make a new Jaxon request.

Click on a Jaxon request in the list, and all its details will appear in multiple tabs. The Response tab will show you the raw response sent by your application.
If this response is not json formatted, then it's the cause of your issue.

from jaxon-core.

feuzeu avatar feuzeu commented on August 19, 2024

Concerning the examples, look at the repo at https://github.com/jaxon-php/jaxon-examples.
These are not "only fragments of code". They are full working examples you can install and run on your own server.
Only by following the simple instructions in the readme, you'll be able to run all the examples excepted those related to frameworks.

It is the same examples I used in this page: https://www.jaxon-php.org/examples.html.

from jaxon-core.

lxaraujo avatar lxaraujo commented on August 19, 2024

from jaxon-core.

feuzeu avatar feuzeu commented on August 19, 2024

Hi,
The link is https://github.com/Xajax/Xajax/blob/master/examples/helloworld.php
Make you include the composer autoload file in your own file. It may exmplain why you cannot create a Response object.

from jaxon-core.

lxaraujo avatar lxaraujo commented on August 19, 2024

Hello,

The Xajax example doesn´t help, I am using it since 2008 and I am very happy with it so I know how to use it.
The composer autoload file is already being loaded because it seems that Jaxon is working. It is creating and injecting the JavaScript parts. I can see inside my file on the debuger that JavaScript is being built and the call to my PHP function from the onclick event is there. The error happen exactly after I click the button. When Jaxon goes to my PHP function and reach $response = new Response the Json that is returned came with the sintax error. The example I need from Jaxon is the kind is shown for Xajax. step by step in the same file, very simple.

from jaxon-core.

lxaraujo avatar lxaraujo commented on August 19, 2024

from jaxon-core.

feuzeu avatar feuzeu commented on August 19, 2024

Hi,
Your issue is not due to debug output as I guessed, but to HTML output.

<?PHP
    if ($jaxon->canProcessRequest()) {
        $jaxon->processRequest();
    }
?>

Since you have put the above code after the HTML code, the response to the Jaxon request will always contain the HTML code and the json data.

Try this

<?PHP
require_once '../vendor/autoload.php';

use Jaxon\Jaxon;
use Jaxon\Response\Response;

$jaxon = jaxon();

$jaxon->register(Jaxon::CALLABLE_FUNCTION, "show");


function show()
{
    $response = new Response();
    $response->assign('div_tab', 'innerHTML', 'texto');
    return $response;
}

if ($jaxon->canProcessRequest()) {
    $jaxon->processRequest();
}
?>
<!DOCTYPE html>
<html>
<head>
<meta content="charset=utf-8" />
<title>Title</title>
</head>
<body style="background-color:#81BEF7 ;">
<form>
<table border="1" align="left" bgcolor="#FFCC33"
style="border-collapse:collapse">
   <tr>
       <td align="right">&nbsp;<input type="button" value="Say Hello"
onclick="<?php echo rq()->call('show') ?>" /></td>
    </tr>
  </table>
  <div id="div_tab"></div>
</form>
<?PHP
    echo $jaxon->getScript(true,true);
?>
</body>
</html>

from jaxon-core.

lxaraujo avatar lxaraujo commented on August 19, 2024

from jaxon-core.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.