============================================================================================================================== ============заполнить расширение Google с данными из локальной базы данных
{
"manifest_version": 2,
"name": "URL pins",
"description": "",
"version": "1.0",
"browser_action": {
"default_icon": "icon.png",
"default_popup": "popup.html"
},
"permissions": [
"http://localhost/pinterest/extension.php"
]
}
==================== popup.js ======== ==============
<script type="text/javascript" language="javascript">
function checkusername(){
var status = document.getElementById("plugin");
var hr = new XMLHttpRequest();
hr.open("GET", "http://localhost/pinterest/extension.php", true);
hr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
hr.onreadystatechange = function() {
if(hr.readyState == 4 && hr.status == 200) {
status.innerHTML = hr.responseText;
}
}
hr.send();
}
}
</script>
======================= popup.html === =======================
<!doctype html>
<html>
<head>
<title>Getting Started Extension's Popup</title>
<style>
body {
min-width: 357px;
overflow-x: hidden;
}
img {
margin: 5px;
border: 2px solid black;
vertical-align: middle;
width: 75px;
height: 75px;
}
</style>
<!--
- JavaScript and HTML must be in separate files: see our Content Security
- Policy documentation[1] for details and explanation.
-
- [1]: http://developer.chrome.com/extensions/contentSecurityPolicy.html
-->
<script src="popup.js"></script>
</head>
<body>
<div id="plugin"></div>
</body>
</html>
============= entension.php ==== ================= ===
<?php
session_start();
include 'database.php';
$uid=$_SESSION['user']['id'];
$string = '<input type="text" name="url" id="url" placeholder="URL...."><br>';
$result = mysql_query("select * from board where userid='$uid'",$con);
$string .="<select name='board'>";
while ($row = mysql_fetch_assoc($result)) {
unset($id, $name);
$id = $row['boardid'];
$name = $row['boardname'];
$string .= '<option value="'.$id.'">'.$name.'</option>';
}
$string .= "</select></br>";
echo $string;
exit();
?>
Я пытаюсь извлечь все доски, которые пользователь создали в базе данных и вытолкнуть его на расширение хром.
Когда я нажимаю на расширение, я вижу пустое всплывающее окно, но когда я запускаю расширение.php в браузере, он показывает ожидаемый результат. Я новичок в расширениях google can any1, пожалуйста, помогите мне с этим?
спасибо !! это сработало. – Shaz