I am trying to write a sample extension, this is how it should work. My extension has an option page, when people click on the sign-in button, it sends an ajax request to test.php and gets information to alert user. But it does not work, I don’t know why.
this is my folder structure
chrome
\ manifest.json
\ options.html
\ options.js
\ test.php
in options.html
<div class="login-button" id="login-button">Sign in</div>
in options.js
$(document).ready(function(){
alert('hello');
$('#login-button').click(function() {
loginAjax();
});
})
function loginAjax() {
$.ajax({
url: 'test.php',
data: "",
dataType: 'json',
success: function(data) {
alert(data);
}
});
}
In the Ajax URL I tried to put an absolute path, but it does not work.
Thanks in advance.
Edit: It already work, i don’t know:-D
you have to use Cross-Origin XMLHttpRequest instead of jquery
see more http://code.google.com/chrome/extensions/xhr.html