SPRedirectWithID can not work on sharepoint 2010

Dec 29, 2013 at 11:18 AM
Edited Dec 29, 2013 at 11:20 AM
Hi all,

I do not know why SPRedirectWithID can not work on sharepoint 2010 for me, I have read most Discussions here and tested all situations with no help!

Is there anyone to help me? Here is my code on newformcustom.aspx:

<asp:Content ContentPlaceHolderId="PlaceHolderMain" runat="server">
<!-- Reference jQuery on the Google CDN --> <script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<!-- Reference SPServices on cdnjs (Cloudflare) --> <script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/jquery.SPServices/0.7.2/jquery.SPServices-0.7.2.min.js"></script>
<script type="text/javascript">
<script type="text/javascript">
<script language="javascript" type="text/javascript">
<script language="javascript" type="text/javascript">
$(document).ready(function() {
$(document).ready(function() {
$().SPServices.SPRedirectWithID({
redirectUrl: "Editform.aspx",
});
});
Dec 29, 2013 at 4:32 PM
Edited Dec 30, 2013 at 1:24 PM
Your mark up looks invalid. You have several <script> aggregates that seems to be open and not closed. They also seem to be encapsulated which is invalid HTML.
Dec 30, 2013 at 4:50 AM
HI

Sorry the mistake in the code was related to copy/paste problem,
This is my code:
<asp:Content ContentPlaceHolderId="PlaceHolderMain" runat="server">
<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/jquery.SPServices/0.7.2/jquery.SPServices-0.7.2.min.js"></script>
<script type="text/javascript">
    $(document).ready(function() {
        $().SPServices.SPRedirectWithID({   
            redirectUrl: "EditForm.aspx",
            });
    });
</script>
Coordinator
Dec 30, 2013 at 1:22 PM
Edited Dec 30, 2013 at 1:23 PM
You still have a comma which will cause a problem at the end of this line:
redirectUrl: "EditForm.aspx",

Since there is no option following that one, there should be no comma.

Also, if you're just getting started with jQuery, I'd recommend using 1.10.2.

M.
Dec 30, 2013 at 4:30 PM
Thanks sympmarc,

Sorry, I'm new in jQuery , I'll test it without comma and will inform you the result,
I have another problem, when I use "jQuery library" and "SPServices" in a Document Library in my site It does not work for me, For example:
<script language="javascript" type="text/javascript" src="/jQueryLibrary/jquery-1.8.3.min.js"></script>
<script language="javascript" type="text/javascript" src="/jQueryLibrary/jquery.SPServices-0.7.2.min.js"></script>
I have downloaded jquery from "http://jquery.com/download/" and tested both "compressed, production jQuery 1.10.2" OR "uncompressed, development jQuery 1.10.2", but no one worked for SPServices.SPAutocomplete while it worked with a CDN use, Would you please let me know the point which causes the issue?

Thanks in advance :)
Coordinator
Dec 30, 2013 at 4:57 PM
It's hard to say since you haven't really described the issue. Are you getting an error? Try reading the General Instructions to ensure that your script references are good.

M.
Jan 1, 2014 at 6:19 AM
HI

Would you please help me to solve my issue as using this Function is important for me,
I tested again "SPRedirectWithID" and it does not redirect me to new URL, I do not get any error message,
<asp:Content ContentPlaceHolderId="PlaceHolderMain" runat="server">
<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/jquery.SPServices/2013.01/jquery.SPServices-2013.01.min.js"></script>
<script type="text/javascript">
    $(document).ready(function() {
        $().SPServices.SPRedirectWithID({   
            redirectUrl: "Editform.aspx",
            debug: true            
            });
    });
</script>
The link before saving my form is "http://portal/Lists/Direct/newform.aspx" and the link after saving is "http://portal/Lists/Direct/AllItems.aspx" , I have inserted the above code in "newform.aspx" via sharepoint Designer,
Your help is appreciated,
Coordinator
Jan 2, 2014 at 2:41 PM
maedehrad:

It's hard to say what the issue is. I suggest you step through the function to see where the issue is. You're probably getting a JavaScript error somewhere.

M.