0

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);
}   

1 Answers1

0

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);}