Question: I am trying to get data from a php sub-page.
Using javascript, I have tried to use :

```js
var items = document.querySelectorAll('option');
console.log("length : "+items.length);
```

```html
  <option value="75">item-127 ( 120127 )</option>
  <option value="74">item-163 ( 0 )</option>
  <option value="94">item-139 ( 0 )</option>
  <option value="89">item-135 ( 0 )</option>
  <option value="369">Item-AC95 ( AC95 )</option>
  <option value="63">item-159 ( 120159 )</option>
```

But it does not return the expected length:
length : 0
How could I do it?

The final expectation is having a table with values and items

thanks

Answer: 
It's error because of 

> 
> The expected message formats for the operation are 'Xml', 'Json'.
>  So you can pass contentType in your ajax call
> 
> 
> 

```
$.ajax({
 ....,

  contentType: "application/json"
})

```
I am not sure, but it depends on what server wants to read from you.

Server does not want to read raw bytes, it wants xml or json

Try to add headers like

```
beforeSend: function(xhrObj){
    xhrObj.setRequestHeader("Content-Type","application/json");
    xhrObj.setRequestHeader("Accept","application/json");
},

```

in $.ajax() function