0

I have an issue with Javascript errors (Object Expected) in normal mode while it works in Edit mode. Its failing on the last line shown below.

$(document).ready(function() { updateListItem(); });

function updateListItem() {

var siteUrl = ‘/sites2/sppwgrqy/DashboardTest/’; alert(‘now to get siteUrl’ + siteUrl );

var clientContext = new SP.ClientContext(siteUrl ); //fails here

No hidden components. works fine in Edit mode. I upgraded to jquery 1.8.3 and then 1.9.0 with no change.

0

1 Answer 1

0

Try this, if it works,

$(document).ready(function() { updateListItem(); });

function updateListItem() {

var siteUrl = ‘/sites2/sppwgrqy/DashboardTest’; 

var clientContext = new SP.ClientContext(siteUrl );

Not sure what's "sppwgrqy" and "DashboardTest" are but format should be something like this '/sites/MySiteCollection'; according to MSDN

Hope it helps.

3
  • ‘/sites2/sppwgrqy/DashboardTest' is simply the Sharepoint Site. Admins have not made SP Designer available to us, Therefore I am usign a CEWP to place this code.
    – Hank
    Commented Jan 29, 2013 at 20:42
  • I see, the problem is while getting ClientContext using Site URL, can you try var siteUrl = ‘/DashboardTest’; and see if it makes any difference :) Commented Jan 29, 2013 at 20:47
  • I have tried changing the siteURL value. It only works in Edit mode as is. Needs a solution that deals with why it works only while in edit mode.
    – Hank
    Commented Jan 29, 2013 at 21:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.