1

I have JSON file generated on my server , but I want to access that data from other host . What should I do on my server , or JSON file to make that data accessible from other domains like JSONP ?

2 Answers 2

1

Assuming it's exposed by some web-accessible method, you need to accept a callback (or similar) parameter which then just becomes a wrapper to the JSON data. e.g.

If you had:

/some/service.json

Which returned:

{"this":"is","JSON":"data"}

You then allow the service to be passed a callback:

/some/service.json?callback=foo

Which in turn results in:

foo({"this":"is","JSON":"data"})

That's all there really is to making the response adhere with JSONP.

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

Comments

0

i think this below code help you

$.ajax({
    type: "POST",
    url: "xyz.com",
    data: jsondata,
    dataType: "jsonp",
    success: function(data) {

        if(data.flag == true){

            alert(data.msg);


        } else {
            alert("not sucess");

        }
    }

    }); 

1 Comment

This is client-side; My understanding is that the OP was asking how to make it available from server-side.

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.