在javascript中,将字符串追加到JSON请求的末尾
我试图将表单中的数据附加到请求中,以便将完整的URL作为请求发送。我知道我可以用PHP做这件事,但我想知道我是否也可以用javascript做这件事 例如,json请求被发送到在javascript中,将字符串追加到JSON请求的末尾,javascript,php,jquery,json,Javascript,Php,Jquery,Json,我试图将表单中的数据附加到请求中,以便将完整的URL作为请求发送。我知道我可以用PHP做这件事,但我想知道我是否也可以用javascript做这件事 例如,json请求被发送到 "http://api.wunderground.com/api/myapi/conditions/q/ZIP.json" 其中,ZIP将由用户提交内容替换 $(function() { $("#getzip").submit(function() { var zip_data =$(this).serial
"http://api.wunderground.com/api/myapi/conditions/q/ZIP.json"
其中,ZIP将由用户提交内容替换
$(function() {
$("#getzip").submit(function() {
var zip_data =$(this).serialize();
$.getJSON("get_weather.php",null , function(data); {
是否可以传递它而不是null?我如何严格地在javascript中将其附加到请求中?似乎需要将其附加到URL字符串本身:
$.getJSON("http://api.wunderground.com/api/myapi/conditions/q/"
+ zip_data, function(data){ return data });
然后在PHP中:
$whatever=filter_input(INPUT_GET,"whatever",FILTER_SANITIZE_STRING);
$somemore=filter_input(INPUT_GET,"somemore",FILTER_SANITIZE_STRING);
$whatever=filter_input(INPUT_GET,"whatever",FILTER_SANITIZE_STRING);
$somemore=filter_input(INPUT_GET,"somemore",FILTER_SANITIZE_STRING);