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: 
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
Instead of this 

```
 var postData = JSON.stringify(companyValue);

```

why don't you try this:

```
var obj ={token :token ,companyValue:companyValue }

```

And then make use of the json stringify function

```
 var postData = JSON.stringify(obj);

```

After that in ajax call only change the url:

```
url: "http://webservice/CompanySave/"

```