Saturday, 30 January 2016

JSONP approach

$.ajax({

url: 'url',
jsonpCallback: "JSON_CALLBACK",
dataType: 'jsonp',
contentType: 'text/plain',
success: function(json) {
console.log(json);
 alert("Success"); },
error: function(jqXHR, textStatus, errorThrown) {
console.log(errorThrown);

alert('Failed!'); },
});

Context :- When JSONP is used for cross domain calls we need to send a parameter '&callback=JSON_CALLBACK ' in this case can we need to alter the output from server to return result wrapped with JSON_CALL

No comments:

Post a Comment

Custom single threaded java server

 package com.diffengine.csv; import java.io.*; import java.net.*; import java.util.Date; public class Server { public static void main(Str...