I'm trying to extend the usability of a photo-gallery site using Greasemonkey.
The site has a thumbnail for each photo gallery and when you click those thumbnails, they open their own gallery pages.
The problem is that the website updates its galleries very often and I forget the last gallery which I've viewed (new galleries moves the old ones to the next pages). I want the web site to remember the galleries which I've visited and show them in different border color.
It's very easy to change their styles on a click event, using jQuery, but want to save the visited gallery IDs to my local database, in order to read them and change their styles when I loaded the page next time.
Here is my post code:
$(".user_gallery").each(function () {
$(this).click(function () {
$("p", this).attr("style", "background-color:yellow");
$.ajax({
type: "POST",
dataType: "json",
contentType: "application/json",
url: "http://localhost:58364/SaveData.aspx/SaveUserGallery",
data: "{'galleryID': '" + $("p", this).text() + "'}",
success: function (data) {
alert("true!");
},
error: function () {
alert("Error calling the web service.");
}
});
});
});
But of course this gives me cross domain errors:
XMLHttpRequest cannot load .... Origin ... is not allowed by Access-Control-Allow-Origin.
My server-side code is simply a .net
web method which runs on my local server and saves galleryIDs to my SQL server db. I'm a member of that photo gallery site and it runs on a different domain.
I'm not an expert web or JS programmer, so I don't know how to solve this problem. How can I do this?