Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Back End Post and Get data from JS to PHP

  • This topic is empty.
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #42528
    kiddo
    Participant

    hi,

    this the first time i’m create a server side so i’m kinda lost in here.. :)

    i want to from my client side to send the data to the server and the server validate the data and send back the response.

    so i found something like this when i was searching

    function submitData() {
    console.log(‘Sending Data’);
    var JSONObject = {};
    var url = ‘http://mywebsite/server/’

    // construct an HTTP reques
    var xhr = new XMLHttpRequest();
    xhr.open(‘POST’, url, true);
    xhr.setRequestHeader(‘Content-Type’, ‘application/json; charset=UTF-8’)

    // send the collected data as JSON
    xhr.send(JSON.stringify(JSONObject));

    xhr.onloadend = function () {
    //check the result & error messages
    };

    }

    i’m need help :(

    thanks in advance.

    #123609
    __
    Participant

    … what is your question?

    #125128
    mweldan
    Member

    I have no idea how to submit form with native js.

    in jQuery you can use $.post or $.get

    example:
    $.post(‘process.php’, {field1: “value”, field2: “value”}, function(result){ //result is response from process.php, such as echo $value etc. });

    hope it helps.

    #125520
    xhtmlchamps
    Participant

    Hello friend
    this is also one of the code for js to php

    session_start();
    // … php code …
    echo ‘‘;
    ?>

Viewing 4 posts - 1 through 4 (of 4 total)
  • The forum ‘Back End’ is closed to new topics and replies.