windows 10 pro office 2019 pro office 365 pro windows 10 home windows 10 enterprise office 2019 home and business office 2016 pro windows 10 education visio 2019 microsoft project 2019 microsoft project 2016 visio professional 2016 windows server 2012 windows server 2016 windows server 2019 Betriebssysteme office software windows server https://softhier.com/ instagram takipçi instagram beğeni instagram görüntüleme instagram otomatik beğeni facebook beğeni facebook sayfa beğenisi facebook takipçi twitter takipçi twitter beğeni twitter retweet youtube izlenme youtube abone instagram

Mithril ajax sending empty inputs

Asked By: Anonymous

I’m trying to send a POST request through ajax and Mithril.js using CodeIgniter. But for some reason the input always is empty. I have tried with a regular ajax post request and that works fine, but Mithril doesn’t.

       m.request({
            method: "POST",
            url: "http://localhost/index.php/login",
            data: {
                username: $("#login-username").val(), 
                password: $("#login-password").val()
            }
        })
        .then(function(result) {
            console.log(result)
        })

And the php

public function login()
    {
        $username = $this->input->post('username');

        die($username);
    }

It always prints “null” in console. Any ideas?

UPDATE:

 <form class="uk-form-stacked uk-margin-remove" id="login-form" method="post" action="index.php/login">
            <fieldset class="uk-fieldset">
                <div class="uk-margin">
                    <div class="uk-inline uk-width-1-1">
                        <span class="uk-form-icon" uk-icon="icon: user"></span>
                        <input class="uk-input" id="login-username" name="username" type="text" placeholder="Username">
                    </div>
                </div>

                <div class="uk-margin">
                    <div class="uk-inline uk-width-1-1">
                        <span class="uk-form-icon" uk-icon="icon: lock"></span>
                        <input class="uk-input" id="login-password" name="password" type="password" placeholder="Password">
                    </div>
                </div>

                <div class="uk-margin" style="margin-top:10px">
                    <label ><input class="uk-checkbox" type="checkbox"> Remember me</label>
                </div>

                <input type="submit" class="uk-button uk-button-primary uk-width-1-1" value="Login">
            </fieldset>
        </form>

Routes:

$route['login']['post'] = 'Users/login';

Solution

Answered By: Anonymous

That code will send a JSON body to the server, not a form submission. I’m guessing your PHP code expects the data to be formatted like a <form> would send it, so for that you’d want to use a FormData instance.

var data = new FormData();

data.append("username", document.querySelector("#username").value);
data.append("password", document.querySelector("#password").value);

m.request({
        method: "POST",
        url: "https://httpbin.org/post",
        data: data
    })
    .then(function(result) {
        console.log(result)
    })

I also set up a JsBin where you can see this working & poke at it.

https://jsbin.com/gififo/2/

techinplanet staff

Porno Gratuit Porno Français Adulte XXX Brazzers Porn College Girls Film érotique Hard Porn Inceste Famille Porno Japonais Asiatique Jeunes Filles Porno Latin Brown Femmes Porn Mobile Porn Russe Porn Stars Porno Arabe Turc Porno caché Porno de qualité HD Porno Gratuit Porno Mature de Milf Porno Noir Regarder Porn Relations Lesbiennes Secrétaire de Bureau Porn Sexe en Groupe Sexe Gay Sexe Oral Vidéo Amateur Vidéo Anal

Windows 10 Kaufen Windows 10 Pro Office 2019 Kaufen Office 365 Lizenz Windows 10 Home Lizenz Office 2019 Home Business Kaufen windows office 365 satın al follower kaufen instagram follower kaufen porno
524 Origin Time-out

524 Origin Time-out


cloudflare-nginx