-
14 Mar 2012 12:12 PM #1
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 (/”/, ”\””)
-
14 Mar 2012 12:42 PM #2Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,710
- Vote Rating
- 436
I think that is an encoding issue there. The JSON should be without the HTML tags.
Mitchell Simoens @SenchaMitch
Sencha Inc, Senior Forum Manager
________________
http://www.JSONPLint.com - Source to lint your JSONP!
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 almost in print!
When posting code, please use BBCode's CODE tags.
-
14 Mar 2012 1:09 PM #3
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.
-
15 Mar 2012 4:43 AM #4Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,710
- Vote Rating
- 436
Mitchell Simoens @SenchaMitch
Sencha Inc, Senior Forum Manager
________________
http://www.JSONPLint.com - Source to lint your JSONP!
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 almost in print!
When posting code, please use BBCode's CODE tags.
-
30 May 2012 7:46 AM #5
Request Form
-
12 Aug 2012 1:20 AM #6
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?


Reply With Quote
