Emre Y
Emre Y

Reputation: 51

How to save ajax post response in to database?

My code is here.

<script type="text/javascript">
    function test(){
        alert('return sent');
        $.ajax({
            type: "POST",
            url: "http://remotewebsite.com/process.php",
            data: somedata;
            dataType:'text'; //or HTML, JSON, etc.
            success: function(response){
                alert(response);
                //echo what the server sent back...
            }
        });
    }
</script>

But how can i save that response coming from remote website in to my database? And how can i send multiple input?

Upvotes: 1

Views: 2019

Answers (1)

guradio
guradio

Reputation: 15565

$.ajax({
    type: "POST",
    url: "http://remotewebsite.com/process.php",
    data: somedata;
    dataType: 'text'; //or HTML, JSON, etc. 
    success: function(response) {
        alert(response);
        $.ajax({
            type: "POST",
            url: "youphppagewhereyoudothesavingindatabase",
            data: response;
            dataType: 'text'; //or HTML, JSON, etc. 
            success: function(data) {
                console.log(data);
                alert("Saved in database")
            }
        });
    }
});

Have it something like this

Upvotes: 1

Related Questions