Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

Im trying to parse json from cross domain but im getting error like 405 (Method Not Allowed) in jquery plugin (im using latest plugin only from google) Any solution or suggestions will be great help for me.

Thanks Basha

Here is my code

$(document).ready(function() {
    $.ajax({
    type: "GET",
    url: "http://myurl.com/webservice&callback=?",          
    contentType: "application/json; charset=utf-8",
    crossDomain: true,
    dataType: "jsonp",
    data: "{}",
    Accept: "",
    beforeSend: setHeader,
    success: OnGetAllMembersSuccess,
    error: OnGetAllMembersError,                
    });
});     
function setHeader(req) {
    req.setRequestHeader("Authentication", "Basic credentials");
    req.setRequestHeader("Content-Type", "application/json");
    req.setRequestHeader("Accept", "application/json");
}    

function OnGetAllMembersSuccess(data, status) {
    alert(status);
    $.each(data.result, function(key, value) {              
        $("#result").append(key+" : "+value);
        $("#result").append("<br />");
    });
}

function OnGetAllMembersError(request, status, error) {
    alert(status);
}   
share|improve this question

1 Answer 1

While using jsonp as dataType, you need to bind a call back function in the server side.. for example, if you need a json response like {"id":"myId"}, at the server side it should be return like "mycallback({"id":"myId"})";

Also you need to write that function in client side too.

function mycallback(json)
{alert(json);}
share|improve this answer

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.