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

Data not recieved by server. #450

Open
ghost opened this issue Apr 6, 2014 · 0 comments
Open

Data not recieved by server. #450

ghost opened this issue Apr 6, 2014 · 0 comments

Comments

@ghost
Copy link

ghost commented Apr 6, 2014

Hello everyone,

First of all I know this is for rails but I like the editor so much that I just need to have it for PHP.
So for about 3 days I have been in a total war to get the data send to the edit/save page.
Finally got it working how it is supossed to work.
Now I am also debugging using the console so I can see what happans.

Here are the results when I am saving :

POST http://localhost/se/backend/bewerk [HTTP/1.1 200 OK 2215ms]
"{"pages/home":{"type":"full","data":{},"value":"<p>This is the homepage.</p>","snippets":{}}}" home:68

So I know it is being send.
Now I am trying to catch the json with php like this :

    public function bewerk() {
        $submit_data = $_POST;
        $json = json_decode($submit_data, true);

        if(isset($json)){
            $data = json_decode($json);
            $this->model->save_data($data);
        } else {
            //$data = var_dump(get_object_vars("object Object"));
            echo json_encode(array("value" => "$json"));
        }
    }

So I am also requesting to get the post that is just sended.

Mercury.PageEditor.prototype.save = function() {
var url = "{{ constant('BASE_URL') }}backend/bewerk";
var data = this.serialize();
Mercury.log('saving', data);
if(this.options.saveStyle != 'form') data = jQuery.toJSON(data);
var method = (this.options.saveMethod == 'PUT') ? 'PUT' : 'POST';
jQuery.ajax(url, {
type: method,
dataType: this.options.saveDataType || 'json',
data: {_method: method, content: data},
success: function() {
Mercury.changes = false;
Mercury.trigger('saved');
console.log(data);
  $.get(url, function( data ) {
  console.log( "Load was performed."+data );
  });
},
error: function() {
alert("Mercury was unable to save to url:\n"+url);
}
});
};

----- 
Result in console : 
GET http://localhost/se/backend/bewerk [HTTP/1.1 200 OK 2280ms]
"Load was performed.{"value":""}" home:70

I hope somebody can help me.
The reason why I want this to work is because I want to use it in al my projects.

Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

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

0 participants