get

jQuery: How to get parameters of a url?

馋奶兔 提交于 2019-11-26 20:00:00
问题 New to jQuery and I'm having trouble getting the parameters of a url that my server generates. I have a url like this: <span class="popuptest"><a href="www.example.com/test?param1=1&param2=2">find param</a></span> my jquery function looks like so: $(function() { $('.popuptest a').live('click', function(event) { $.extend({ getUrlVars: function(){ var vars = [], hash; var hashes = this.href.slice(this.href.indexOf('?') + 1).split('&'); for(var i = 0; i < hashes.length; i++) { hash = hashes[i]

How can I send POST and GET data to a Perl CGI script via the command line?

こ雲淡風輕ζ 提交于 2019-11-26 19:45:21
问题 I am trying to send a get or a post through a command-line argument. That is test the script in the command line before I test through a browser (the server has issues). I tried searching online, and I suppose I was probably using incorrect terminology because I got nothing. I know this is possible because I saw someone do it. I just don't remember how it was done. Thanks! :) 回答1: Are you using the standard CGI module? For example, with the following program (notice -debug in the arguments to

Use jQuery to get the file input's selected filename without the path

百般思念 提交于 2019-11-26 19:22:08
I used this: $('input[type=file]').val() to get the file name selected, but it returned the full path, as in "C:\fakepath\filename.doc". The "fakepath" part was actually there - not sure if it's supposed to be, but this is my first time working with the filename of file uploads. How can I just get the file name (filename.doc)? var filename = $('input[type=file]').val().split('\\').pop(); or you could just do (because it's always C:\fakepath that is added for security reasons): var filename = $('input[type=file]').val().replace(/C:\\fakepath\\/i, '') You just need to do the code below. The

JQuery ajax call to httpget webmethod (c#) not working

岁酱吖の 提交于 2019-11-26 18:56:55
I am trying to get an ajax get to a webmethod in code behind. The problem is I keep getting the error "parserror" from the jQuery onfail method. If I change the GET to a POST everything works fine. Please see my code below. Ajax Call <script type="text/javascript"> var id = "li1234"; function AjaxGet() { $.ajax({ type: "GET", url: "webmethods.aspx/AjaxGet", data: "{ 'id' : '" + id + "'}", contentType: "application/json; charset=utf-8", dataType: "json", async: false, success: function(msg) { alert("success"); }, error: function(msg, text) { alert(text); } }); } </script> Code Behind [System

How to get an input text value in JavaScript

巧了我就是萌 提交于 2019-11-26 18:33:54
How go get an input text value in JavaScript? <script language="javascript" type="text/javascript"> lol = document.getElementById('lolz').value; function kk(){ alert(lol); } </script> <body> <input type="text" name="enter" class="enter" value="" id="lolz"/> <input type="button" value="click" OnClick="kk()"/> </body> When I put lol = document.getElementById('lolz').value; outside of the function kk() , like shown above, it doesn't work, but when I put it inside, it works. Can anyone tell me why? The reason you function doesn't work when lol is defined outside it, is because the DOM isn't loaded

How to set $_GET variable

可紊 提交于 2019-11-26 18:30:47
问题 How do i set the variable that the $_GET function will be able to use, w/o submitting a form with action = GET ? 回答1: You can create a link , having get variable in href. <a href="www.site.com/hello?getVar=value" >...</a> 回答2: $_GET contains the keys / values that are passed to your script in the URL. If you have the following URL : http://www.example.com/test.php?a=10&b=plop Then $_GET will contain : array 'a' => string '10' (length=2) 'b' => string 'plop' (length=4) Of course, as $_GET is

Beautiful way to remove GET-variables with PHP?

时光怂恿深爱的人放手 提交于 2019-11-26 18:21:24
I have a string with a full URL including GET variables. Which is the best way to remove the GET variables? Is there a nice way to remove just one of them? This is a code that works but is not very beautiful (I think): $current_url = explode('?', $current_url); echo $current_url[0]; The code above just removes all the GET variables. The URL is in my case generated from a CMS so I don't need any information about server variables. Justin Ok, to remove all variables, maybe the prettiest is $url = strtok($url, '?'); See about strtok here . Its the fastest (see below), and handles urls without a '

Making href (anchor tag) request POST instead of GET? [duplicate]

拟墨画扇 提交于 2019-11-26 18:15:42
问题 This question already has an answer here: Make a link use POST instead of GET 11 answers <a href="employee.action" id="employeeLink">Employee1</a> when i click the Employee1 link, GET request goes to server. I want to make it POST instead of GET request. Is there a way i can change default GET behaviour of href? Note:- I know it can be done where we can call javascript function on hyperlink click , then create form and submit it. But i am looking where we can mention some attribute in anchor

Why shouldn't data be modified on an HTTP GET request?

五迷三道 提交于 2019-11-26 17:43:07
I know that using non-GET methods (POST, PUT, DELETE) to modify server data is The Right Way to do things. I can find multiple resources claiming that GET requests should not change resources on the server. However, if a client were to come up to me today and say "I don't care what The Right Way to do things is, it's easier for us to use your API if we can just use call URLs and get some XML back - we don't want to have to build HTTP requests and POST/PUT XML," what business-conducive reasons could I give to convince them otherwise? Are there caching implications? Security issues? I'm kind of

Node.js Express route naming and ordering: how is precedence determined?

北战南征 提交于 2019-11-26 17:23:50
问题 Say I've got a few GET routes on my Express application: // music albums app.get('/api/albums', routes.albums.getAlbums); app.get('/api/albums/:id', routes.albums.getAlbum); app.get('/api/albums/artwork', routes.albums.getAlbumArtwork); and I attempt to hit them using the follow jQuery AJAX snippet: $("#retrieveAlbumArtwork").on("click", function() { $.ajax({ url: "api/albums/artwork", type: "GET", data: { artist: $("#albumArtist").val(), title: $("#albumTitle").val() }, // ... callbacks and