I have a $.get() AJAX call to response.php but after configuring a virtual host on XAMPP I get this error :
jquery.js:9631 GET http://mipl.local/response.php?operation=delete_node&code=Power_source&text=fsfsfsssddfsfs 404 (Not Found)
'mipl.local' is the server name after configuration. Here is my code where I make the AJAX call:
$.get('response.php?operation=delete_node', {
'code': data.node.parent,
'text': data.node.text
});
Any suggestions please?
I fixed the problem with adding the global url not the short one
Related
So i am new to Angular4, I have a service that is supposed to make a request to a php api. I have the following code -
getWeather(keyword: string){
return this.http.get("weather.php", {
params: new HttpParams().set('keyword', keyword),
headers: new HttpHeaders().set('Method', 'search'),
});
I am getting a 404 localhost:4200/weather.php cannot be found. not sure wher to place the php endpoint file.
Assuming that localhost:4200 is your front-end server, you have to set your php server api path in the call. If your php server in in local on the 8080 port, you type this.http.get('http://localhost:8080/weather.php',...
You can put it in your src/assets folder and then call it using this.http.get("assets/weather.php", {....
This is because for Angular application is hosted on 4200 port and your PHP file will be using port 80.
Try using
http://localhot/path/to/weather.php
I have build a REST server and trying to make my java application communicate to it.
But I keep getting a 404 error.
When I type in the url in my browser along with the function name like:
[url]/controller/functionname/1.json
it works fine, returning me the right data.
Without the function name:
[url]/controller/1.json
I get this error:
"action 1.json not defined in controller".
I've checked my .htaccess file and routes against a previous version I had build which was working just fine. I can't figure out what the problem might be. Any suggestions?
And oh, I should mention, the earlier version that I talked about was build on windows and this one on ubuntu.
I've got a very basic one today! I'm trying to post from jQuery to a PHP file hosted on localhost.
My JS:
$("#searchNameButton").click(function() {
var name = $("#searchNameText").val();
$.ajax({
type: 'POST',
url: 'localhost:8080/getNameInfo.php', // -> this works fine from the browser
// data: { name: name }, -> commented out
success: function(){
alert('request successful');
},
error: function(xhr, textStatus, errorThrown){
alert('request failed');
}
})
});
My PHP file (getNameInfo.php), a very basic one for testing:
<?php
echo 'TEST';
?>
In jQuery, it will always bring me to error, saying 'Internal Server Error'.
I am using Ripple Emulator and this is what appears in the console:
POST https://rippleapi.herokuapp.com/xhr_proxy?tinyhippos_apikey=ABC&tinyhippos_rurl=localhost%3A8080/getNameInfo.php
500 (Internal Server Error)
I assume it has to do more with this than with what's written in the files. Any advice? Thanks!
EDIT: Found this: LINK but it won't fix my issue. If I do what it says here, I won't get any error thrown ("" instead) but will still fail.
EDIT 2: If I set Cross-Domain Proxy to Local in Ripple (that's suggested in the link above) I get
OPTIONS http://localhost:4400/ripple/xhr_proxy?tinyhippos_apikey=ABC&tinyhippos_rurl=http%3A//localhost%3A8080/getNameInfo.php net::ERR_CONNECTION_REFUSED
EDIT 3: Changed my URL to local
C://Mobile//Cross-Platform//TestApp//www//php//getNameInfo.php
and it's working now. Have no idea how to make it work on localhost. BUt will go with this now, as it's only a learning app.
Add a header access control at top of getNameInfo.php file :
header('Access-Control-Allow-Origin: *');
So, finally I found a solution.
Even though it's not a recommended one, running Chrome with
--disable-web-security
will allow me to call a PHP script hosted on localhost:8080 from localhost:3000 where PhoneGap / Ripple Emulator stays.
I have an ajax call for login:
$.ajax({
url: url_to_ajax,
success: function ( data ) {
switch (data) {
case "-2": input1.addClass("has-error");
break;
case "-1": input1.addClass("has-error");
break;
case "0": input2.addClass("has-error");
break;
case "1": //everythings ok
window.location.replace(base_url);
break;
default: //this should not happens
window.location.replace(base_url);
break;
}
}
});
And chrome console gives me this:
GET http://testserv.local/profil/login_call/admin#gmail.com/ross 404 (Not Found)
When I copy this URL in browser, everythings is ok and it shows me result code. On live server is everything ok. But on localhost this.. And for me, the biggest mistery is, that the url is called with that ajax, because after refresh page I'm logged in..
Can someone help me?
I am using wamp, Apache 2.4.9, PHP 5.5.12 on windows 8.1
EDIT: I was writing this code a month before, everythings were ok on live and on localhost.. After I formated disc and install new W8.1 this code doesn't work.
After 6 hours i resolved it.. Just put
header("HTTP/1.1 200 OK");
In your code if you have the same "magic" problem as me..
It's not a problem with AJAX, but with the server.
The error that you're getting is 404 Not Found. That means that the web server at "testserv.local" exists and is responding, but couldn't find the resource you're looking for. Have you made any change to the local server, recently? What happens if you open http://testserv.local/profil/login_call/admin#gmail.com/ross on your browser? And what about each of:
http://testserv.local/profil/login_call/admin#gmail.com
http://testserv.local/profil/login_call/
http://testserv.local/profil/
http://testserv.local/
(I am asking this because if you're using those urls, maybe the mod_rewrite in Apache stopped working because you changed some configuration)
I have encountered a very strange problem in using jQuery load(). I used it to load a php file in a div container. It's working fine on my localhost but on the server it does not load the php file and instead gives
Failed to load resource: the server responded with a status of 500 (Internal Server Error)
I don't know why is this happening. My jQuery code is:
//ADD THE Description TO THE HOLDER
infofield.append('<div id="'+opt.style+' description" class="'+opt.style+' description">'+item.data('desc')+'</div>');
// ATTACHED the comments to the LIGHTBOX
$('.description').load('gallery_comments.php?id='+id+'&pic='+imgsrc+'&a'+ab);
Is there a server issue? Using on localhost with WAMP server and testing cross browser compatibility it runs in all browsers, even in IE8. Can any one help?
update ** just used chrome and found out one bug in Uncaught ReferenceError: $ is not defined in line 9 and line 9 code is
$(function() {
$('div.viewgp').hide();
$('.slidegp').click(function() {
$('.viewgp').fadeToggle(200);
});
});
You say you can access gallery_comments.php directly, but with what query string parameters? Are you sure that you use the same ones which are appended via the values of id, imgsrc, and ab in the following line?
$('.description').load('gallery_comments.php?id='+id+'&pic='+imgsrc+'&a'+ab);
Try the following changes to determine exactly what you're trying to load, and navigate directly to the url that comes to your console or alert box:
var url = 'gallery_comments.php?id='+id+'&pic='+imgsrc+'&a'+ab;
console.log(url); // or alert(url);
$('.description').load(url);
If I wanted to play psychic debugging, these would be my first two guesses:
one of the parameters is required server side, but is null / empty / undefined in your javascript
There is an attempt to access a resource that is accessible on your localhost environment but not on the remote server environment