Skip to content

How do I transfer data from a client-side form input to a server-side Nodejs script then to parse server? #3366

@alexrmacleod

Description

@alexrmacleod

I am looking to do the following:

http://stackoverflow.com/questions/32700914/how-do-i-transfer-data-from-a-client-side-form-input-to-a-server-side-nodejs-scr

`
Client Side

function select() {

 var id = $('#My-ID-Input').val();

 $.ajax({
    type: 'post',
    url: '/id',
    data : {
         id : id
    },
    success: function(data) {
         var id = data.id;
         $('#My-ID-Input').val(id);
    },
    error: function(err) {
         console.log(err);
    }

});

}
Server Side

app.post('/id', function(req, res) {

var data = req.body;
var id = data.id;

var query = "SELECT * FROM Control WHERE id=" + id;
connection.query(query, function(error, result) {
    console.log(result);
    res.send(result);
});

});
`

In the above example inside the "connection.query" I am thinking of saving data from form into a parse server app.

So HTML form > ajax with jquery > node server > save object from form to parse server app?

So if I replace the ajax with something like the following

https://www.parse.com/questions/using-jquery-and-ajax-to-assign-uploaded-file-to-new-parse-object
`
$.ajax({
type: "POST",
beforeSend: function(request) {
request.setRequestHeader("X-Parse-Application-Id", 'YourAppIDkey');
request.setRequestHeader("X-Parse-REST-API-Key", 'YourRestAPIkey');
request.setRequestHeader("Content-Type", file.type);
},
url: serverUrl,
data: file,
processData: false,
contentType: false,
success: function(data) {

`

How do I direct it to the right cloudcode function to define and save the object?

Or should I do something like this:

http://stackoverflow.com/questions/2138527/php-curl-http-post-sample-code

Just looking for a bit of guidance any help is appreciated.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions