0

Does anyone see anything wrong with the following:

$.ajax({
    url: '/tags/ajax/post-tag/',
    data: { newtaginput : $('#tag-input').val(), customerid : $('#customerid').val()},
    success: function(data) {
        // After posting
        alert(data);
        arr = data.tagsinserted.split(',');
        alert(arr);
        //Loop through
        $.each(arr, function(n, val){
            alert(n + ' ' + val)
        }); 
    }
}, "json"); 

tagsinserted is what's being returned, here is the full response:

{"returnmessage":"The Ajax operation was successful.","tagsinserted":"b7,b4,dog,cat","returncode":"0"}

Thanks

1
  • 2
    my javascript interpreter eyes say - "its all good". no wait, what is "json" doing all alone by himself? shouldn't it be part of settings inside the first param. as in { .. , dataType: "json" }); Commented Mar 19, 2010 at 4:03

1 Answer 1

1

Anurag is right in his comment json needs to be dataType:'json'

also, unless specified, request is "GET" by default, your url suggests it is expecting post data, i.e. type:'post'

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.