1. #1
    Touch Premium Member
    Join Date
    Oct 2011
    Posts
    5
    Vote Rating
    0
    dschere is on a distinguished road

      0  

    Default You're trying to decode an invalid JSON String

    You're trying to decode an invalid JSON String


    I am trying to make an Ext direct call using a script on the server side. Why is this not compliant json?

    You're trying to decode an invalid JSON String: <html><body><textarea>{"tid": 1, "action": "api", "type": "rpc", "method": "foo", "result": "hello world"}</textarea></body></html>


    Based on this excerpt from the documentation at
    http://www.sencha.com/products/extjs/extdirect


    I tried wrapping quotes with slashes and got the same result.

    This response will be JSON encoded. The router can send back multiple transactions within a single response enclosed in an array. If the request was a form post and it was an upload the response will be sent back as a valid html document with the following content:


    <html><body><textarea>{YOUR JSON RESPONSE HERE}</textarea></body></html> " must be back-slashed because the textarea will convert them to actual quotes. Therefore you must do a regular expression (/”/, ”\””)



  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,404
    Vote Rating
    850
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    I think that is an encoding issue there. The JSON should be without the HTML tags.
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

  3. #3
    Touch Premium Member
    Join Date
    Oct 2011
    Posts
    5
    Vote Rating
    0
    dschere is on a distinguished road

      0  

    Default


    According to the http://www.sencha.com/products/extjs/extdirect specification

    this is the reply that the sencha client expects from the server:

    <html><body><textarea>{YOUR JSON RESPONSE HERE}</textarea></body></html>

    I also tried replacing quotes with \" but that didn't seam to make a difference.

    I guess what I really need is a sample of a good response xml/jspn text to model off of.

    Thanks for the reply.



  4. #4
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,404
    Vote Rating
    850
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    Quote Originally Posted by mitchellsimoens View Post
    I think that is an encoding issue there. The JSON should be without the HTML tags.
    as I said ^^^

    JSON looks like this:

    Code:
    {"foo":"bar","hello":"hi"}
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

  5. #5
    Sencha User
    Join Date
    Jun 2011
    Posts
    2
    Vote Rating
    0
    csc_03 is on a distinguished road

      0  

    Default Request Form

    Request Form


    Problem: not escaping the html tags. thank

    directbundle.jpg

  6. #6
    Sencha User
    Join Date
    Aug 2012
    Posts
    3
    Vote Rating
    0
    hashimserag is on a distinguished road

      0  

    Default Same error here..

    Same error here..


    <?
    $conn = mysql_connect ("localhost", "root", "") or die (mysql_error ());
    mysql_select_db ("extjs") or die (mysql_error ());
    $q=mysql_query ("
    INSERT INTO info (to, subject, msg) VALUES ('".$_POST['to']."','".$_POST['subject']."','".$_POST['msg']."')
    ") or die ('{"success":"false"}');
    // json output to notify the insert is success or not
    if ($q) {
    echo '{"success":"true"}';
    }
    else {
    echo '{"success":"false"}';
    }
    ?>

    I get the same error in my code shown above and i have no idea whats wrong, i can see that i did write the Json code correctly or didn't i?