Closed rajatkumcom closed 6 years ago
Getting this error ( SyntaxError: Unexpected token < in JSON at position 0 ) when trying to use:- storageManager: { type: 'remote', autosave: false, setStepsBeforeSave: 1, contentTypeJson: true, params: {}, storeComponents: true, storeStyles: true, storeHtml: true, storeCss: true, urlStore: 'http://localhost/grapesjs/fileUpload.php', urlLoad: 'http://localhost/grapesjs/fileLoad.php', }
Could someone please help me... Thanks in advance!
Can you give more details?
I think your problem in this endpoint http://localhost/grapesjs/fileLoad.php.
When I am trying to save, then I got that error. Loading is perfect.
This is my code:-
I have done changes in grapes.js file which is not recommended var typeJson = this.get('contentTypeJson'); var typeJson = false;
Resolved issue.
No need to modify GrapesJS code. Just set 'contentTypeJson' to false in storeManager config if your endpoint uses application/x-www-form-urlencoded when storing the template.
var editor = grapesjs.init({
...
storageManager: {
...
contentTypeJson: false,
...
}
});
....
If I will set it as false, So while loading it creates problem.
It generate this output in console:-
Loaded {0: "{", 1: """, 2: "g", 3: "j", 4: "s", 5: "-", 6: "h", 7: "t", 8: "m", 9: "l", 10: """, 11: ":", 12: """, 13: "<", 14: "f", 15: "o", 16: "r", 17: "m", 18: " ", 19: "c", 20: "l", 21: "a", 22: "s", 23: "s", 24: "=", 25: "\", 26: """, 27: "f", 28: "o", 29: "r", 30: "m", 31: "\", 32: """, 33: ">", 34: "<", 35: "d", 36: "i", 37: "v", 38: " ", 39: "c", 40: "l", 41: "a", 42: "s", 43: "s", 44: "=", 45: "\", 46: """, 47: "f", 48: "o", 49: "r", 50: "m", 51: "-", 52: "g", 53: "r", 54: "o", 55: "u", 56: "p", 57: "\", 58: """, 59: ">", 60: "<", 61: "l", 62: "a", 63: "b", 64: "e", 65: "l", 66: " ", 67: "c", 68: "l", 69: "a", 70: "s", 71: "s", 72: "=", 73: "\", 74: """, 75: "l", 76: "a", 77: "b", 78: "e", 79: "l", 80: "\", 81: """, 82: ">", 83: "N", 84: "a", 85: "m", 86: "e", 87: "<", 88: "\", 89: "/", 90: "l", 91: "a", 92: "b", 93: "e", 94: "l", 95: ">", 96: "<", 97: "i", 98: "n", 99: "p", …}
@rajatkumcom your server have to set a correct header output, eg. in php it should be something like this
header('Content-Type: application/json');
echo json_encode($data);
Thank you....
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
WARNING
READ and FOLLOW next 5 steps, then REMOVE them before posting the issue
[Bug]: ....
You're submitting a BUG
grapesjs.version
in console and press ENTERYou're submitting a FEATURE REQUEST