What could cause $.getJSON to return XML?!
in Using jQuery
•
8 years ago
This is just so weird that I felt compelled to post...
I am using jQuery's $.getJSON function to retrieve a list item from a SharePoint 2013 list. Here is the relevant code:
I am using jQuery's $.getJSON function to retrieve a list item from a SharePoint 2013 list. Here is the relevant code:
- /*
Function to display the fields for the selected product
*/
function WriteProductFields()
{
var myURL = "https://SPserver/this/that/_vti_bin/ListData.svc/TheList(" + productId + ")";
step1 = $.getJSON(myURL,function(data) {
/* First, grab values to be stored for later use */
productLine = data.d.PL; ...
Various issues contributed to it taking me some time to get this working, one of which was due to first working on pulling the entire list. The returned JSON object has a different structure, when retrieving only a single list item. Grrrr.
This is working fine in Chrome and the hated IE. BUT (and this is a BIG BUT), a small number of the items in the list are always being returned in XML format, when I use Firefox (!?!). It's the same site, using the same back-end jQuery(-1.9.1.min.js), but I'm seeing this different outcome in different browsers -- AND I'm getting XML back from a call to $.getJSON!!
I saw a post from one person on this forum (stormcroww), saying that some characters are handled incorrectly by SharePoint, which can result in invalid JSON being returned. Still, returning XML instead of JSON just seems "right out", as some might say.
And are the code paths within jQuery significantly different, for different browsers?
I gotta say, this one kinda freaks me out...
Thanks!
1