Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GetJson problem or missing file #1

Open
ereallstaff opened this issue Apr 18, 2012 · 9 comments
Open

GetJson problem or missing file #1

ereallstaff opened this issue Apr 18, 2012 · 9 comments

Comments

@ereallstaff
Copy link

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
Copy link
Collaborator

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
Copy link
Author

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/100000776133691<ereallstaff@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:
#1 (comment)

@bluelovers
Copy link
Collaborator

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
Copy link
Collaborator

@ereallstaff
Copy link
Author

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(){ *

  • *
    
  •  $.ajax( *
    
  •    { *
    
  •      url : "
    
    http://localhost.dev/ModaNuovo/webapp/index.php?sum1=1&sum2=2", *
  •      datatype:"json", *
    
  •      success: function(data){*
    
  •          alert ('success');*
    
  •          $('#ciao').html(data);*
    
  •      },*
    
    ...
    *
    *
    Ajax Response
    *
    *
    _$var = $_REQUEST['sum1'] ; *
    *$var2 = $REQUEST['sum2'] ;
    echo '

    questa è la somma risultante'.$var+$var2.'

    '; // echoes
    correctly 3

    *
    *
    PhpQueryCall
    _echo $SERVER["HTTP_HOST"];
    _$url='http://
    '.$SERVER["HTTP_HOST"].'/ModaNuovo/webapp/provaAjax.php?sum1=1&sum2=2';
    _phpQuery::ajaxAllowHost($SERVER["HTTP_HOST"].'/ModaNuovo/');
    *
    *
    $data['function'] = 'addProduct';
    *
    *
    $doc=phpQuery::ajax(array(
  • 'type' => 'POST',*
  • 'url' => $url*
  • 'data' => $data);*
    *
    *
    Ajax server response
    _$var = $_REQUEST['sum1'] ; *
    $var2 = $REQUEST['sum2'] ;
    echo '

    questa è la somma risultante'.$var+$var2.'

    '; *
    // echoes *
    null* as for him all request is null

    *
    *

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/100000776133691<ereallstaff@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:
#1 (comment)

@bluelovers
Copy link
Collaborator

if u use datatype:"json"

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

@ereallstaff
Copy link
Author

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:
#1 (comment)

@bluelovers
Copy link
Collaborator

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
Copy link
Author

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:
#1 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants