Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/261.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在javascript中,将字符串追加到JSON请求的末尾_Javascript_Php_Jquery_Json - Fatal编程技术网

在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

我试图将表单中的数据附加到请求中,以便将完整的URL作为请求发送。我知道我可以用PHP做这件事,但我想知道我是否也可以用javascript做这件事 例如,json请求被发送到

"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);