CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Sep 2011
    Posts
    3

    Question Ajax query, Javascript and Sharepoint

    Hello everyone.

    I am struggling with a sharepoint project containing Ajax query. I am fairly new in C#/Ajax/Sharepoint development and don't a clear understanding.

    I am working on a bug. The scenario is as following. There is a small form which is saving information or is supposed to save information. Instead I am getting an error

    Sys.ArgumentUndefinedException: Value cannot be undefined. Parameter name:method

    The last code line from following is causing the error

    function saveOrderSucceeded(sender, args) {

    if ($("#" + ddOrderLiftingId).val() != "") {
    try {

    var list = currentWeb.get_lists().getByTitle('Person');
    var listItem = list.getItemById($("#" + ddOrderLiftingId).val());
    currentSPContext.load(listItem, 'WorkPhone', 'CellPhone');
    currentSPContext.executeQueryAsync(Function.createDelegate(listItem, function () {
    var item = this.get_fieldValues();
    var phoneNumbers = [];

    if (item.WorkPhone != null)
    phoneNumbers.push(item.WorkPhone);

    if (item.CellPhone != null)
    phoneNumbers.push(item.CellPhone);

    if (phoneNumbers.length > 0)
    $("#" + orderLiftingPhoneId).html("Phone. " + phoneNumbers.join(", "));

    }),
    Function.createDelegate(this, this.ajaxQueryFailed)); //error occurs in here. Below is the function where this is pointing to.

    ................
    ................

    function ajaxQueryFailed(sender, args) {
    alert(args.get_message());
    }

    I debugged this by using Firebug and it shows that 'ajaxQueryFailed', when executed is 'undefined'. I don't know how to start solving this. Help would be appreciated.

    Thanks in advance.

  2. #2
    Join Date
    Apr 2009
    Posts
    598

    Re: Ajax query, Javascript and Sharepoint

    Maybe, a right parenthesis is missing in:
    currentSPContext.executeQueryAsync(Function.createDelegate(listItem, function () {
    N.B. Please, place your lines of code between [code] and [/code].
    Last edited by olivthill2; September 2nd, 2011 at 09:38 AM.

  3. #3
    Join Date
    Sep 2011
    Posts
    3

    Re: Ajax query, Javascript and Sharepoint

    Thanks for th reply olivthill and advices.

    I Believe the code has all the brackets correctly

    Code:
    currentSPContext.executeQueryAsync(Function.createDelegate(listItem, function () { 
    
    ...
    
    }),
    
    Function.createDelegate(this, this.ajaxQueryFailed));

  4. #4
    Join Date
    Sep 2011
    Posts
    3

    Re: Ajax query, Javascript and Sharepoint

    The same query is working on the same file in following code

    Code:
    function getLatestWorksite() {
        try {
            var query = camlQueryLatestWorksite.format(currentUserId);
    
            var list = currentWeb.get_lists().getByTitle("Work sites");
            var camlQuery = new SP.CamlQuery();
            camlQuery.set_viewXml(query);
    
            var items = list.getItems(camlQuery);
    
            currentSPContext.load(items, 'Include(ID, Title, WorkSiteRegistry_CustomerID, WorkSiteRegistry_Address, CustomerID, CustomerName)');
            currentSPContext.executeQueryAsync(Function.createDelegate(items, this.populateLatestWorksite),
                                               Function.createDelegate(this, this.ajaxQueryFailed));
        } catch (e) {
    But I am not able to figure out the differency that is relevant in this case.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured