我試圖從一個簡單的MySQL數據庫中檢索數據,這個數據庫在我的Macbook Pro上用MAMP進行本地管理。如何從iPhone上的MAMP MySQL數據庫檢索數據?
當我在Xcode的模擬器中運行項目時,它完美地工作。按下按鈕時將從數據庫中檢索數據。當您在Netbeans中運行代碼時,它也可以在Google Chrome瀏覽器中運行。
當我運行通過的Xcode在設備上的代碼,應用程序看起來應該和導航像它應該,但是當推按鈕未檢索數據。
我必須通過我的IP地址,以便爲它在設備上工作的連接?誰能解釋一個簡單的方法來做到這一點?請。
下面是檢索數據的代碼;
$(document).on('click', '#studentButton',function() {
$.getJSON('http://localhost:8888/htdocs/php/json-data-students.php', function(data) {
$.each(data.students, function(index, student) {
$('#Row1').append('<p> ID: ' + student.studentID+ '</p>');
$('#Row2').append('<p> < '+ student.firstName +' > ')+ '</p>';
$('#Row3').append('<p> < '+ student.lastName +' > ')+ '</p>';
$('#Row4').append('<p> Course ID: ' + student.courseID+ '</p');
});
});
});
用相關代碼更新您的問題,顯示如何建立連接。 – rmaddy
@rmaddy編輯。這是檢索數據的代碼。 – Skin99