Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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.

share|improve this question
add comment

1 Answer 1

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.

share|improve this answer
    
‘/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 Jan 29 '13 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 :) –  Muhammad Raja Jan 29 '13 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 Jan 29 '13 at 21:27
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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