query-string

Decoding query strings in PHP

主宰稳场 提交于 2019-12-10 17:12:19
问题 Okay, so I've written a REST API implementation using mod_rewrite and PHP. I'm accepting a query string via the body of HTTP DELETE requests (... collective groan?). Arguments about the wisdom of both previous statements aside, what I've found is that PHP doesn't automatically parse the request body of DELETE requests (i.e. $_POST is empty despite form-encoded query string appearing in body of request). This didn't particularly surprise me. What I did find surprising was that I've been unable

How can I check if there is a query string from a Ruby on Rails controller?

非 Y 不嫁゛ 提交于 2019-12-10 16:59:41
问题 I'm using pagination on our Ruby on Rails app and the pages are defined in the request with a query string parameter like http://ourdomain.com/?page=2 I use this on our front page where there's no page number explicitly defined. I'd like to do a check to see if there is a query string, and if not then display the correct page=1, by redirecting to that page I presume Does anyone know how I can do this? Thanks ahead for any help 回答1: if params[:page].blank? redirect_to :page => 1 end 回答2:

How can I access the entire query string in an ASP.net controller action

寵の児 提交于 2019-12-10 14:59:43
问题 I know that if I have an url like XController/Action?id=1, and an action method void Action(int id) the id parameter will automatically be read from the query string. But how can I access the entire query string when I don't in advance know the name of all parameters. E.g: void Action(QueryStringCollection coll) { object id = coll["id"]; } Is it possible to do something like this? 回答1: Use Request.QueryString for this Request.QueryString.Keys gives you the name of all parameters 来源: https:/

PHP: How to check if query string or POST vars contain same var twice

一笑奈何 提交于 2019-12-10 14:23:09
问题 It may sound strange, but in my PHP application I need to check if the same variable name has been declared more than once in the query string or POST variables, and return an error value if this is the case. If my application doesn't return an error in this case, it fails a compliance check. When accessing vars using $_GET, $_POST, etc, PHP only returns the last value given for each variable name. I can't find a way to tell if any variable appeared more than once. I simply need to find out

How to get the hashtag value and ampersand value of a url in Javascript?

て烟熏妆下的殇ゞ 提交于 2019-12-10 14:13:51
问题 I have a url like http://www.example.com/folder/file.html#val=90&type="test"&set="none"&value="reset?setvalue=1&setvalue=45" Now I need to get the portion of url from starting from #, How do I get that, I tried using window.location.search.substr(); but looks like that searches for ? in a url. is there a method to get the value of url after # How do I also get a portion of url from ampersand & Thanks, Michael 回答1: var hash = window.location.hash; More info here: https://developer.mozilla.org

How to pass query parameter as string into jquery load that includes space

那年仲夏 提交于 2019-12-10 13:59:29
问题 Hi i have a simple question. I want to know how to pass a query string into a query parameter using jquery. function loadPage(queryString) { jQuery("#divId").load("myurl/action?param=" + queryString); } queryString could be like "1,2,3,4" or "testing 1 2 3". When I tried it only the first parameter is their. I want to be able to pass in a sentence, or a paragraph. 回答1: try function loadPage(queryString) { jQuery("#divId").load("myurl/action?param=" + encodeURIComponent(queryString)); } 回答2:

How to make ASP.NET to stop interpret null as string

百般思念 提交于 2019-12-10 12:32:36
问题 I have a Web API method: public List<Task> GetTasks([FromUri] TaskFilter filter) { } The method has parameter with list of nullable identifiers: public class TaskFilter { public IList<int?> Assignees { get; set; } } When I call it: GET /tasks?assignees=null Server returns an error: { "message":"The request is invalid.", "modelState": { "assignees": [ "The value 'null' is not valid for Nullable`1." ] } } It works only if I pass empty string: GET /tasks?assignees= But standard query string

How do I pass the # symbol as part of a GET querystring in the URL?

試著忘記壹切 提交于 2019-12-10 12:18:50
问题 I am using javascript (using jquery) to pass a # symbol as a GET parameter via AJAX call. The problem right now is that the # symbol is breaking up my querystring. Any help appreciated. Thanks! 回答1: You need to replace it with %23 in the string. However, instead of doing this directly you should use Javascript function encodeURIComponent to encode characters in the URL. Alternatively, if you are using jQuery.ajax you can automatically encode parameters by passing them in via the data option.

Codeigniter and Pagination with Query Strings

ε祈祈猫儿з 提交于 2019-12-10 12:15:42
问题 I am trying to build a Search with Pagination in Codeigniter and would love some help with it. So far, I've realized that I can not use BOTH url segments and query strings together. Using only query strings produces very ugly URLs. I understand that Codeigniter destroys the GET and I'm trying to put it back in. Ergo... if I place this in the constructor of the search controller, will my problems be solved? parse_str(substr(strrchr($_SERVER['REQUEST_URI'], "?"), 1), $_GET); As in, if it works

Block 'kw=' Query String

早过忘川 提交于 2019-12-10 11:55:58
问题 I keep getting nonsense hits to my site like: myurl.com/?kw=antivirus*protection myurl.com/?kw=a+casino myurl.com/?kw=.confused.com myurl.com/?kw=whatevernonsense Also, if it matters, it is a self-hosted Wordpress site. I've tried many permutations to the following, but it isn't working: <IfModule mod_rewrite.c> RewriteEngine On RewriteCond %{QUERY_STRING} kw RewriteRule ^(.*)$ - [F,L] </IfModule> Edit: I've tested the above code in a separate directory, and it works fine. Below is the