jquery - json for making a cross browser request -
sorry if duplicating qn. none of answers present me solution cross browser request problem.
i need send request different url using json , required headers. tried following code doesnt seems working.
it takes 3 parameters..
var url = 'url?firstname=myname&lastname=mylastname&email=myemail'; $.ajax({ type: 'get', url: url, datatype: 'jsonp', success: function(){ alert("hi"); }, error: function() { alert( 'something goes wrong!' ); } });
the output 'something goes wrong!'. working when copy url in browser area. looking accomplish same through jquery , json formatted input. need pass required headers.
much appreciated if let me know missing above code?
while using jsonp datatype, need bind call function in server side.. example, if need json response {"id":"myid"}, @ server side should return "mycallback({"id":"myid"})";
also need write function in client side too.
function mycallback(json) {alert(json);}
Comments
Post a Comment