old-blueday / phpQuery

clone from phpQuery svn. phpQuery is a server-side, chainable, CSS3 selector driven Document Object Model (DOM) API based on jQuery JavaScript Library.
http://code.google.com/p/phpquery/
11 stars 3 forks source link

GetJson problem or missing file #1

Open ereallstaff opened 12 years ago

ereallstaff commented 12 years ago

Hello I am trying use this:

phpQuery::ajax(array( 'type' => 'GET', 'url' => $url, 'data' => array('prova'=>'ciao'), 'success' => getJsCallback($doc), 'dataType' => 'json', ));

But it satys :

Warning: require_once(Zend/Json.php): failed to open stream: No such file or directory in /home/giuseppe/homeProj/phpQuery/phpQuery/phpQuery/Zend/Json/Decoder.php

So I added manually from ZendFramework Zend/Json.php Zend/Json/Expr.php

And it gives me : Fatal error: Uncaught exception 'Zend_Json_Exception' with message 'Illegal Token'

Could you check please? Thankls

bluelovers commented 12 years ago

u need set zendframework path in php.ini or put this code on php file top

set_include_path(get_include_path() . PATH_SEPARATOR . 'D:/Users/Documents/The Project/ZendFramework-1.x/library/');

change the path for your zend path

zend version need is 1.x

ereallstaff commented 12 years ago

It does not solve the problem I have still following issue

Fatal error: Uncaught exception 'Zend_Json_Exception' with message 'Illegal Token' in /home/giuseppe/homeProj/ZendFramework1/ZendFramework-1.11.11/library/Zend/Json/Decoder.php on line 457

I have another problem, sorry if I take advantage of your time :

all variables put in " data " field of phpQuery::ajax are not in request inside landing page ( this is a cross domain call )

$data['function'] = 'addProduct';

$doc=phpQuery::ajax(array(

    'type' => 'GET',

    'url' => $url,

    'data' => $data,

    'success' =>  getJsCallback($doc)

));

and in landing page I use

echo $_REQUEST['function'] // echoes nothing!

Servizio Clienti ModaCalcio.com email --> ereallstaff@gmail.com, info@modacalcio.com MSN messenger --> peppons_6@hotmail.itchrome-extension://mce_host/msnim:chat?contact=peppons_6@hotmail.it Skype --> ereallstaff skype:ereallstaff?chat | Mobile --> 0039 348 4939119 (vodafone) Facebook --> Aggiungi Giuseppe Modacalcio http://it-it.facebook.com/people/Modacalcio-Giuseppe/100000776133691

Modacalcio.com gruppo E-reall sport, via Ariosto 3, 87100 Cosenza, Italy - Piva VAT IT 02763220783

http://www.modacalcio.com skype:ereallstaff?chatchrome-extension://mce_host/msnim:chat?contact=peppons_6@hotmail.ithttp://it-it.facebook.com/people/Modacalcio-Giuseppe/100000776133691ereallstaff@gmail.com?subject=Iscrizione%20Newsletter&body=Inseriscimi%20nella%20newsletter http://www.ilveggente.it 2012/4/18 bluelovers < reply@reply.github.com

u need set zendframework path in php.ini or put this code on php file top

set_include_path(get_include_path() . PATH_SEPARATOR . 'D:/Users/Documents/The Project/ZendFramework-1.x/library/');

change the path for your zend path


Reply to this email directly or view it on GitHub: https://github.com/bluelovers/phpQuery/issues/1#issuecomment-5207531

bluelovers commented 12 years ago

my test issue and it work fine

replace 'success' => getJsCallback($doc) with 'success' => 'getJsCallback'

r.php

<?php

/**
 * @author bluelovers
 * @copyright 2012
 */

require_once (dirname(__file__) . '/../bootstrap.php');

$url = 'http://' . $_SERVER["HTTP_HOST"] . str_replace('r.php', 's.php', $_SERVER["PHP_SELF"]);

phpQuery::ajaxAllowHost($_SERVER["HTTP_HOST"]);

$data['function'] = 'addProduct';

$doc = phpQuery::ajax(array(
    'type' => 'GET',
    'url' => $url,
    'data' => $data,
    'success' => 'getJsCallback'));

function getJsCallback($doc)
{
    echo $doc;
}

s.php

<?php

/**
 * @author bluelovers
 * @copyright 2012
 */

echo $_REQUEST['function'];
bluelovers commented 12 years ago

https://github.com/bluelovers/phpQuery/tree/g/issue/1/issue/1

ereallstaff commented 12 years ago

Ok I found where is the problem

the script now works correctly effectively I wrote bad the callback function

But the problem with request remains.

I am trying to make an ajax call to a file inside a joomla website of mine.

If I do a normal jquery getjson call it goes all ok and the request is fine. Instead if I send the call from php from same external point the request goes cancelled. Do maybe there is any rule in htaccess for this maybe ? or maybe any other header to send that I omit :(((

Unfortunately I need it in php as to add a Json call to the current structure is quite impossible

Thanks for your effort

Jquery call $(document).ready(function(){

Servizio Clienti ModaCalcio.com email --> ereallstaff@gmail.com, info@modacalcio.com MSN messenger --> peppons_6@hotmail.itchrome-extension://mce_host/msnim:chat?contact=peppons_6@hotmail.it Skype --> ereallstaff skype:ereallstaff?chat | Mobile --> 0039 348 4939119 (vodafone) Facebook --> Aggiungi Giuseppe Modacalcio http://it-it.facebook.com/people/Modacalcio-Giuseppe/100000776133691

Modacalcio.com gruppo E-reall sport, via Ariosto 3, 87100 Cosenza, Italy - Piva VAT IT 02763220783

http://www.modacalcio.com skype:ereallstaff?chatchrome-extension://mce_host/msnim:chat?contact=peppons_6@hotmail.ithttp://it-it.facebook.com/people/Modacalcio-Giuseppe/100000776133691ereallstaff@gmail.com?subject=Iscrizione%20Newsletter&body=Inseriscimi%20nella%20newsletter http://www.ilveggente.it 2012/4/19 bluelovers < reply@reply.github.com

https://github.com/bluelovers/phpQuery/tree/g/issue/1/issue/1


Reply to this email directly or view it on GitHub: https://github.com/bluelovers/phpQuery/issues/1#issuecomment-5210996

bluelovers commented 12 years ago

if u use datatype:"json"

the Ajax server response url need return json data but ur script is return html data

ereallstaff commented 12 years ago

If i put json I get the send exception illegal token. I am wondering why the same identical request works perfectly with jQuery and partially with your library. There may be something different in sending headers or setting cookie? I don t know. Thanks for assistance

Il giorno giovedì 19 aprile 2012, bluelovers < reply@reply.github.com> ha scritto:

if u use datatype:"json"

the Ajax server response url need return json data


Reply to this email directly or view it on GitHub: https://github.com/bluelovers/phpQuery/issues/1#issuecomment-5224859

bluelovers commented 12 years ago

the new jqueryserver demo fix it https://github.com/bluelovers/phpQuery/tree/g/f/php/namespace/1/jQueryServer

error illegal token because use json parse html data

u can see the commit log for changes

now use use phpquery parse html and return json

ereallstaff commented 12 years ago

Hello it's me again :DD

I am having some problem in integrating your library into a fully namespaced project (i.e. symfony)

I ha ve to parse an external htm page, and usig the library as a standaline it works great.

When i pur ito my doctrine 2 project it not. The error is inside he pq function and i think the problema may be inside your instanceof statement, ihave seen you use many of them.

May you be iterested i solvig this issue? I can Try help you! 2012/4/19 bluelovers < reply@reply.github.com

the new jqueryserver demo fix it

error illegal token because use json parse html data

u can see the commit log for changes

now use use phpquery parse html and return json


Reply to this email directly or view it on GitHub: https://github.com/bluelovers/phpQuery/issues/1#issuecomment-5226921