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

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

Closed
alexrmacleod opened this issue Jan 13, 2017 · 0 comments

Comments

@alexrmacleod
Copy link

alexrmacleod commented Jan 13, 2017

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.

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

1 participant