Question: I am trying to pass the value stored in the function argument to the PHP page using data, however Ajax always executes the error section generating the popup - alert.

The code is attached below. Any suggestions. thanks in advance

```
function clickonaccept(contentid)
{

    $.ajax
    ({
        type: 'POST',
        url: '../scripts/s_updateinvites.php',
        data: { id: contentid},
        error: function() 
        {
           alert('Error!');
        },
        success: function(data) 
        {
           alert ('updatedt!');
        }
    });
}

```

**contents of script s\_updateinvites.php**

```
<?PHP

    include_once ("s_dbconnect.php");
    $connectobject= new dbconnect();

    $con = $_POST["id"]; 

    $connectobject->query("INSERT INTO workingon (Content_ID) VALUES ('$con')");

?>

```

Answer: 
This is a bit of a hacky answer, but it works:

```
##Define breaks
co2$brks<- cut(co2$rank, c(seq(0, 100, 5), max(co2$rank)))
#Create a plot object:
g = ggplot(data=co2, aes(x = tons, fill=brks)) +
   geom_dotplot(stackgroups = TRUE, binwidth = 0.05, method = "histodot")

```

Now we manually specify the colours to use as a palette:

```
 g + scale_fill_manual(values=colorRampPalette(c("white", "red"))( length(co2$brks) ))

```

![enter image description here](https://i.stack.imgur.com/UHrKi.png)
I just needed to add 

```
+ scale_fill_brewer(palette="RdYlBu")

```

See below:

```
library(reshape2)
library(ggplot2)

co2 <- read.table(
  header=TRUE, text='
rank tons
1     2 1.00
2     4 1.00
3     7 0.00
4    44 0.00
5   104 0.00
6    48 0.05
7    32 0.50
8     5 0.00
9    78 1.00
10   12 0.00
11   15 0.00
12  176 1.00
13  440 0.02
14  249 0.00
15  481 0.00
16  388 0.00
17  458 0.05
18  488 0.00
19  264 0.00
20  203 0.00
            ')                                                                                                          

#create breaks for fill--
co2$brks<- cut(co2$rank, c(seq(0, 100, 20), max(co2$rank)))
e<- ggplot(data=co2, aes(x = tons, fill=brks)) 
e + geom_dotplot(stackgroups = TRUE, binwidth = 0.05, method = "histodot")  + scale_fill_brewer(palette="RdYlBu")

#also works correctly!
ggplot(data=co2, aes(x = tons, fill=brks)) + geom_histogram() + scale_fill_brewer(palette="RdYlBu")

```