this does work fine as long the homepage var has no // in it
$.getJSON(url + "/addPerson/'" + name + "'/'" + homepage +"'", function(data){console.log(data);} );
how would I correctly prepare an url var to pass it as JSON call ?
this does work fine as long the homepage var has no // in it
$.getJSON(url + "/addPerson/'" + name + "'/'" + homepage +"'", function(data){console.log(data);} );
how would I correctly prepare an url var to pass it as JSON call ?
If homepage
is an URL with http://
in it you need encode it.
You should write :
$.getJSON(url + "/addPerson/" + name + "/" + encodeURIComponent(homepage), function(data){console.log(data);} );
If that is the case, you should not pass urls in urls. Use the POST payload or multiform data.
Also, if the aim of the request is to add a record in your database, use POST instead of GET.
$.post(url+'/addPerson', {name: name, homepage: homepage}, function(data){console.log(data);});
Use encodeURI
to encode the uri and get the correct value to the api, when trying to access a api over http