저는 jquery와 jquery mobile을 사용하는 것에 익숙 합니다만 jquery mobile에 데이터베이스 (원격 및 로컬)를 묶는 간단한 방법 (또는 튜토리얼 선호도)이 있는지 궁금합니다. 사이트 (php를 사용하지 않는 것이 좋음).jquery 모바일 사이트에 데이터베이스 추가하기
답변
당신은 자바 스크립트를 통해 HTML5 로컬 스토리지를 사용할 수 있습니다, 여기에 대한 설명 및 튜토리얼에 대한 몇 가지 링크입니다 : http://www.html5rocks.com/en/features/storage
이 ... 이제 응용 프로그램이 클라이언트 기기에 데이터를 저장할 수있는 몇 가지 기술이있다 ..
서버와 상호 작용하려면 서버 측 스크립팅 언어를 사용해야합니다.
//run the following code whenever a new pseudo-page is created
$(document).delegate('[data-role="page"]', 'pagecreate', function() {
//cache this page for later use (inside the AJAX function)
var $this = $(this);
//make an AJAX call to your PHP script
$.getJSON('path_to/server/script.php', function (response) {
//create a variable to hold the parsed output from the server
var output = [];
//if the PHP script returned a success
if (response.status == 'success') {
//iterate through the response rows
for (var key in response.items) {
//add each response row to the output variable
output.push('<li>' + response.items[key] + '</li>');
}
//if the PHP script returned an error
} else {
//output an error message
output.push('<li>No Data Found</li>');
}
//append the output to the `data-role="content"` div on this page as a listview and trigger the `create` event on its parent to style the listview
$this.children('[data-role="content"]').append('<ul data-role="listview">' + output.join('') + '</ul>').trigger('create');
});
});
PHP--
<?php
//include your database connection code
include_once('database-connection.php');
//query your MySQL server for whatever information you want
$query = mysql_query("SELCT * FROM fake_table WHERE fake_col='fake value'", $db) or trigger_error(mysql_error());
//create an output array
$output = array();
//if the MySQL query returned any results
if (mysql_affected_rows() > 0) {
//iterate through the results of your query
while ($row = mysql_fetch_assoc($query)) {
//add the results of your query to the output variable
$output[] = $row;
}
//send your output to the browser encoded in the JSON format
echo json_encode(array('status' => 'success', 'items' => $output));
} else {
//if no records were found in the database then output an error message encoded in the JSON format
echo json_encode(array('status' => 'error', 'items' => $output));
}
?>
당신은 또한 당신의 PHP 스크립트로 데이터를 전송할 수 있으며,
JS-- : 그것은 당신의 서버와 통신 할 수 AJAX를 사용하여 매우 쉽게 그것을 데이터베이스에 추가하십시오.
jQuery를 .getJSON()
: http://api.jquery.com/jquery.getjson
PHP json_encode()
: http://www.php.net/json_encode
사용 그것은 스토리지의 여러 가지 방법을 제공하며, 실제로 모든 넣을 수 http://westcoastlogic.com/lawnchair/
여기
이상 사용하는 기능에 대한 몇 가지 문서 페이지입니다 브라우저에서 사용할 수있는 첫 번째 어댑터를 가져 오도록 순서대로 어댑터 (저장 방법 옵션)를 지정하십시오. localstorage 또는 sqlite를 사용하려는 경우에도 JSON 형식을 사용하므로 JSON 데이터 만 처리하면됩니다.
데이터베이스를 원하면 모바일 브라우저 내부의 SQLLite에 대한 지원이 Web SQL Databases 형태로되어 있으며, 현재 대부분의 Android 및 iPhone 장치에서 지원됩니다.
가 동작하는 예제는 다음 링크를 확인해 보려면 : SQLLite에서 사용할 수있는 SQL 언어보다 더 제한http://desalasworks.com/html5-databases-on-iphone/
하는 것으로 (내가 가정하는 것은) MySQL 데이터베이스를. 테이블을 작성/삭제하고 선택, 삽입 및 업데이트 할 수 있지만 고급 작업 중 일부는 누락됩니다.
- 1. 모바일 사이트에 Google지도 포함
- 2. MVC3 jQuery 모바일 사이트에 양식을 제출하십시오
- 3. 사이트에 비디오 추가하기
- 4. 모바일 사이트에 사용자를 유지하십시오.
- 5. 웹 사이트에 CMS (wordpress) 추가하기?
- 6. 장고 웹 사이트에 'CRM'기능 추가하기
- 7. 웹 사이트에 슬라이딩 사운드 추가하기
- 8. 내 웹 사이트에 '좋아요'버튼 추가하기
- 9. 웹 사이트에 자바 스크립트 추가하기
- 10. 웹 사이트에 여러 언어 추가하기
- 11. 웹 사이트에 Apple Icon 추가하기
- 12. 내 웹 사이트에 OpenID 추가하기
- 13. 웹 사이트에 "게시"기능 추가하기
- 14. 기존 웹 사이트에 magento 추가하기
- 15. EditText를 사용하여 데이터베이스 추가하기
- 16. 모바일 웹 사이트에 Google지도 표시
- 17. PHP 프레임 워크가 jquery + HTML5 모바일 웹 사이트에 사용합니까?
- 18. JQuery 모바일. 사이트에 하나의 https 페이지 만 있음
- 19. 모바일 사이트에 jQuery 정렬 식을 사용할 수 있습니까?
- 20. 사이트에 데이터베이스 생성 시간
- 21. 모바일 앱용 sqlite 데이터베이스
- 22. 모바일 데이터베이스 동기화
- 23. 내 웹 사이트에 좋아하는 버튼 추가하기
- 24. 내 장고 사이트에 보안 질문 추가하기
- 25. 현재 웹 사이트에 로그인 논리 추가하기
- 26. 업로드/스캐닝 화면을 웹 사이트에 추가하기
- 27. 자바 스크립트를 사용하여 웹 사이트에 버튼 추가하기
- 28. 페이스 북 추가하기 CodeIgniter 웹 사이트에 연결하기
- 29. 웹 사이트에 사용자 정의 오류 페이지 추가하기
- 30. MapInnovations가 포함 된 웹 사이트에 Google지도 추가하기