datetimepicker ajax mysql php
Set jQuery datepicker allowed times with ajax call
I need to set jQuery datepicker plugin allowed times by an ajax call
This is my javascript:
And this is my php code in «getdate.php».
But both of them didn’t work. (I’m using this plugin ‘http://xdsoft.net/jqplugins/datetimepicker/’)
2 Answers 2
If you want to get the value of the property via an AJAX call you have to make sure that your call will be finished and successful before displaying your time picker. I think that this method can cause latency.
I thought of an other solution :
After some testing I found the answer. We need to add these to ajax call parameters.
dataType: «json»,
contentType: «application/json; charset=utf-8»,
So this is my js,
This is my php,
Not the answer you’re looking for? Browse other questions tagged php jquery datepicker or ask your own question.
Related
Hot Network Questions
Subscribe to RSS
To subscribe to this RSS feed, copy and paste this URL into your RSS reader.
site design / logo © 2021 Stack Exchange Inc; user contributions licensed under cc by-sa. rev 2021.9.16.40224
By clicking “Accept all cookies”, you agree Stack Exchange can store cookies on your device and disclose information in accordance with our Cookie Policy.
JQuery datepicker not working after ajax call
I have the following code
5 Answers 5
You need to reinitialize the date picker in Ajax success
The answer you are looking for may be similar to this question: jQuery datepicker won’t work on a AJAX added html element
You’re replacing the datepicker element in the DOM with the ajax response. The reason this works for the first time is that PHP renders the my_ajax_stuff.php on first load already in the HTML so it becomes available to jQuery in the DOM.
I came across this question because I was having the same problem as OP.
Mooed Farooqui’s recommendation to reinitialize in Ajax success worked, but not initially.
This may be a primitive solution, but I found that If I have in my main document a function MakeDatePicker and I used it in the OnChange portion of my input, I was able to make any object, ajax, or otherwise, turn into a date picker before, and after an ajax call. Here is the function and the call. (please note, I have ColdFusion # functions, as this is a return on a coldfusion query with a CFOutput.)
here is the function at the top of my page:
like I said, its crude, but it works.
как создать отчет между двумя датами, используя datepicker, ajax, php, mysql.?
Мне была поставлена задача создать отчет между двумя датами, используя datepicker, ajax, php и mysql. ниже мой html:
Отчет по дате
Вот файл php, который должен генерировать отчет: bet_date.php
Проблема в том, что когда я выбираю обе даты, ничего не происходит. любезно помогите мне в этой ситуации. простые примеры были бы весьма полезны. Благодарю.
измените свой html на это: у вас есть showUser() not showuser() поэтому измените входной onchage=»showUser()».
напишите onchange событие как на inputs.so в обоих полях, которые они вызывают. и в вашей дате использования sql (дата), если вы отправляете только дату из столбца front-end и date в базе данных, введите тип datetime..
надеюсь, что вы получите сообщение/получить параметры правильно в php.
test.php (файл вызова ajax)
эта демонстрация отлично работает, и только сейчас я создал так, как только ее проверили…
Пожалуйста, кто-нибудь получит интерес, чем исправить ответ и дать голосование за это решение.. Спасибо
Убедитесь, что дата, переданная средством выбора даты с использованием AJAX, имеет правильный формат, подходящий для вашего запроса.
Попробуйте отобразить эти две переменные, переданные HTML-датчиком на вашей странице PHP:
Это даст вам подсказку о любой проблеме, если таковая имеется.
bootstrap datetimepicker dateformat saving to mysql
i have tried several ways to convert date selected with datetimepicker to save it in my mysql database but none of them works.
i want to save this format:
but i have this saved:
any suggestions? Many tks
My code to select date:
3 Answers 3
A little late to the party but you can use the following to grab input on submit. This was designed for converting multiple inputs but can be edited to run on just one as well if you so desired.
The following allows you to display your time selections in 12 hour format, as well as have datetimepicker js apply to any dynamically created elements.
btw, datetimepicker requires moment.js so before you submit run this to save to mysql.
To display the time as you had mentioned you may need to apply the styling to the date when you’re rendering it.
Setup your MySQL field as a DATETIME column, then do this to your datetimepicker:
There are some things to know about Bootstrap datepicker.
You can do so by the client side or sever side. Always is better work in client side so save resources of our server. You can build also a function inside your PHP to convert to MySQL format your POST string.
Remember if you process at client side you need to send the POST in MySql Format(YYYY-mm-dd for DATE) or (YYYY-mm-dd H:i:s for DATETIME or TIMESTAMP)
Ex.: // Format your datetimepicker with Mysql format
Now you can push this value on a hidden field: HTML:
You also can get the original string without treatment and process in PHP. something like this (only for YYYY-mm-dd format):
В этом уроке мы наглядно проиллюстрируем, насколько просто получить доступ к информации из базы данных с помощью AJAX, мы собираемся создавать запросы MySQL на лету и отображать результаты в виде таблицы HTML.
Пример работы с Ajax, PHP и MySQL
В следующем примере показано, как веб-страница может получать информацию из базы данных с помощью AJAX. Вы можете из выпадающего списка выбрать одного из клиентов и увидите, что, без перезагрузки страницы, необходимая информация будет отображаться ввиде таблицы HTML:
Example
Таблица примера работы с Ajax и MySQL
В базе данных demo создадим таблицу ajax_demo:
Пример
Теперь выгрузите следующие данные в эту таблицу, используя следующие операторы SQL:
Пример
В результате мы получим следующую таблицу, которую будем исползовать в этом уроке:
Объяснение примера работы с Ajax и MySQL
Функция showUser() запускается событием onchange :
Пример
Сначала проверим, выбран ли человек из списка. Если никто не выбран (str == «»), то очистим содержимое элемента с и выйдем из функции. Если же человек выбран, то выполним следующие шаги:
Файл-обработчик для работы с Ajax и MySQL
Страница на сервере, вызываемая выше приведенным JavaScript, представляет собой PHP-файл «getuser.php».
Исходный код в файле «getuser.php» выполняет запрос к базе данных MySQL и возвращает результат в таблице HTML:
Пример
Объяснение кода: Когда запрос отправляется из JavaScript в файл PHP, происходит следующее:









