Ok, here is what I am trying to do. I have a list on another site. I have successfully connected to the site and pulled in the list as a dropdown using soap, ajax and jquery. However, once I try and submit the new item, it gives me an error. Here is the code I am using,

    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js" type="text/javascript"></script>
    <script type="text/javascript">
$(document).ready(function() {
var soapEnv =
    "<soapenv:Envelope xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/'> \
        <soapenv:Body> \
            <GetListItems xmlns='http://schemas.microsoft.com/sharepoint/soap/'> \
                <listName>b9ac31cc-ea35-4df1-af50-4e3fa9e86b1c</listName> \
                <viewName>7E918A0F-631B-4B3B-81FD-B27C98586DC4</viewName> \
                    <viewFields> \
                        <ViewFields> \
                            <FieldRef Name='Title' /> \
                        </ViewFields> \
                    </viewFields> \
            </GetListItems> \
        </soapenv:Body> \
    </soapenv:Envelope>";

    $.ajax({
        url: "/sites/wellness/_vti_bin/lists.asmx",
        type: "POST",
        dataType: "xml",
        data: soapEnv,
        complete: processResult,
        contentType: 'text/xml; charset="utf-8"'
    });

    $('#addThis').bind('click',function(){
        var choice = $('#chooseOrg').val();
        alert(choice);
        $('#ctl00_m_g_03d6c665_34ef_42f1_9e55_ae2a2560edc7_ff4_1_ctl00_ctl00_TextField').val(choice)
    });
});

function processResult(xData, status) {
    $(xData.responseXML).find("[nodeName='z:row']").each(function() {
        //$('#chooseOrg').
        $('#ctl00_m_g_83e35e85_85ae_4056_9d87_b56fe029295b_ff41_ctl00_DropDownChoice').
        append($("<option></option>").
        attr("value",$(this).attr("ows_Title")).
        text($(this).attr("ows_Title")));
    });
};
</script>

Here is the Error Screen. Image of error

If I remove the soap/ajax/and jquery it adds a new item like it is supposed to, Any Ideas??

link|improve this question

75% accept rate
Can you find the Correlation ID in the logs and post the relevant error messages? – rjcup3 Mar 28 at 14:08
I don't have access to the error logs, I have sent the request to another member on my team to see if they can find them for me. Any ideas without?? – Brenton Pierce Mar 28 at 14:12
Well that's the error that displays for almost every error in SharePoint. Have you tried tracing it with FireBug or IE F12 Developer Tools to see what the service response is? – rjcup3 Mar 28 at 14:23
I mean, you are using a relative url. Are you sure the endpoint is available from the location you're running it? – rjcup3 Mar 28 at 14:25
Yes, it is available, If I take out the dynamic dropdown options, sharepoint saves just like it is supposed to – Brenton Pierce Mar 28 at 14:33
show 2 more comments
feedback

1 Answer

up vote 2 down vote accepted

I think the issue is that the options you are adding to the select don't have the same ids as the values in the source list. You're using the Title for both the option text and the value. Assuming that the DropDownChoice is a Lookup column, you need to use the right id for each option to match what would be saved if you weren't running your script.

link|improve this answer
ok, do you know of a way to add them to the list column? I am not sure how to do that. The list column is a "Choice" dropdown. – Brenton Pierce Mar 28 at 18:09
You can't add arbitrary values to the Choice column dropdown; the only values which are allowable are those which you've got in the list settings. – Marc D Anderson Mar 28 at 18:27
ok, thanks for you assistance on this. What I ended up doing was pulling in the values into the dropdown and then having the user add that to a textbox. It works good, a bit klunky but it works. – Brenton Pierce Mar 28 at 18:30
You could add those disallowed values to the text box yourself in your script, since you'll know which ones you've added. – Marc D Anderson Apr 7 at 20:56
feedback

Your Answer

 
or
required, but never shown

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