Hướng dẫn jquery send value to php - jquery gửi giá trị tới php

Vì có vẻ như bạn là người mới trên Ajax, chúng ta hãy thử một cái gì đó đơn giản hơn ok? Kiểm tra điều này js:


var string = "my string"; // What i want to pass to php

 $.ajax[{
    type: 'post', // the method [could be GET btw]
    url: 'output.php', // The file where my php code is
    data: {
        'test': string // all variables i want to pass. In this case, only one.
    },
    success: function[data] { // in case of success get the output, i named data
        alert[data]; // do something with the output, like an alert
    }
}];

Bây giờ đầu ra của tôi.phpoutput.php

Bài Viết Liên Quan

Chủ Đề