JSON call with url as parameter
This question already has an answer here:
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);});
尝试通过http访问api时,使用encodeURI
对uri进行编码并获取正确的值给api
上一篇: &reg在jQuery中变得®
下一篇: 以url作为参数的JSON调用