Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 313
  • Last Modified:

php file not opening

I'm trying to open a php while passing along these three values.  I know I'm at the point because my alert is coming up, but file is not opening.  Any help is appreciated.  Thank you.

case "Place":
	alert("Hello Place");
	var Rid = $('#Doggie').val(), Cid = $('#Kitty').val(),	Aid = $('#Pig').val();
	$.post('ajax/result_place.php', { Rid: "Rid", Cid: "Cid", Aid: "Aid"} );
	break;

Open in new window

0
DS928
Asked:
DS928
1 Solution
 
DS928Author Commented:
Tried this, but still not opening...

$(document).ready(function()
{
var Rid = $('#Doggie').val(), Cid = $('#Kitty').val(),	Aid = $('#Pig').val();
$.ajax({
type: "POST",
url: "result_place.php",
data: {"Rid":Rid,"Cid":Cid,"Aid":Aid}, 
cache: false,
success: function (html) {
}
});
})

Open in new window

0
 
sivagnanam chandrakanthTechnical LeadCommented:
Are you sure the path of the file is right???

What is showing in firebug?
0
 
DS928Author Commented:
Path is right.  I have fuve different php files that I can possibly load.  Maybe there is a way from javascript that I can change the form action to select the proper file?
0
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
Lukasz ChmielewskiCommented:
OK, try this and see what the error is

$(document).ready(function()
{
var Rid = $('#Doggie').val(), Cid = $('#Kitty').val(),	Aid = $('#Pig').val();
$.ajax({
type: "POST",
url: "result_place.php",
data: {"Rid":Rid,"Cid":Cid,"Aid":Aid}, 
cache: false,
success: function (html) {
},
error: function (xhr, ajaxOptions, thrownError){
alert(thrownError);
}
});
})

Open in new window

0
 
DS928Author Commented:
Path is right.  I have fuve different php files that I can possibly load.  Maybe there is a way from javascript that I can change the form action to select the proper file?
0
 
DS928Author Commented:
OK, no error, no nothing?  Here is where the code is being called from.  The alert comes up so I assume that whatever is behind the alert is also coming up?

<form onsubmit="return doSomething();">
<select name="Doggie" size="20" style="width:250px" class="Doggie" id="Doggie" >
</select>
<select name="Kitty"  size="20" style="width:250px" class="Kitty" id="Kitty" >
</select>
<select name="Pig"  size="20" style="width:250px" class="Pig" id="Pig">
</select>
        
<input type="submit" value="Show" name="select" />
 <label for="Kitty"></label>
 <div align="center"></div>
 <label for="Pig"></label>
 <div align="center"></div>
 <div align="center">
 <p>
<input type="hidden" input name="Glass" id="Glass"/>
</p>
</form>

Open in new window


and the function being called.
function doSomething() {
    var g = $("#Glass").val();
	switch(g)
	{
	case "Place":
	$(document).ready(function()
	{
	var Rid = $('#Doggie').val(), Cid = $('#Kitty').val(),	Aid = $('#Pig').val();
	$.ajax({
	type: "POST",
	url: "result_place.php",
		data: {"Rid":Rid,"Cid":Cid,"Aid":Aid}, 
		cache: false,
		success: function (html) {
		},
		error: function (xhr, ajaxOptions, thrownError){
		alert(thrownError);
		}
		});
		})
		break;
	case "Cuisine":
	$(document).ready(function()
	{
	var Cid = $('#Doggie').val(), Aid = $('#Kitty').val(),	Fid = $('#Pig').val();
	$.ajax({
	type: "POST",
		url: "result_cuisine.php",
		data: {"Cid":Cid,"Aid":Aid,"Fid":Fid}, 
		cache: false,
		success: function (html) {
		},
		error: function (xhr, ajaxOptions, thrownError){
		alert(thrownError);
		}
		});
		})
		break;
	case "City":
		alert("Glass = " + g);
		break;
	case "State":
		alert("Glass = " + g);
		break;
	case "ZipCode":
		alert("Glass = " + g);
	break;
	}
	
	
	return false;
}

Open in new window

0
 
crazedsanityCommented:
It seems to me that the most likely error here is that you're using a relative URL instead of an absolute one, so it only seems like it's going to the right place.  If the actual URL is "/ajax/result_cuisine.php", and it's called from "/menu/something.php", the actual URL that it will try to use would be "/menu/ajax/result_cuisine.php".

I would suggest trying this in Chrome (Chromium on Linux) or Firefox.  In Chrome, there's a "javascript console" under the tools submenu, which has a "network" tab: bring that up, and watch the javascript run... if there's an error, it will appear in the console or (most likely) you'll get a 404 error or similar in the network tab.  In Firefox, just install Firebug, activate it, and do the same thing.
0
 
crazedsanityCommented:
What I sometimes do to actively debug javascript (without having to set breakpoints in it) is to write the *.js file so it has callable functions.  Once it's written, I load the page & use the browser's Javascript console to execute the command and view the results.  With some simple logging to the console using console.log("stuff") (don't use this in IE, it will cause the JS to break), I've been able to find and fix the problems pretty quickly.
0
 
DS928Author Commented:
Thank you, I will try these.
0
 
DS928Author Commented:
OK, gave up on this.  I switched it to this, changing the form action dynamicaly and that is working fine.
Code in the form....
<form name="Animals" method="post" onsubmit="return OnSubmitForm();">

Open in new window

The function...
function OnSubmitForm() {
    var g = $("#Glass").val();
	switch(g)
	{
		case "Place":
			document.Animals.action ="result_place.php";
                                   break;
		case "Cuisine":
			document.Animals.action ="result_cuisine.php";
		break;
		case "City":
			document.Animals.action ="result_city.php";
		break;
		case "State":
			document.Animals.action ="result_state.php";
		break;
		case "ZipCode":
			document.Animals.action ="result_zip.php";
		break;
	}
}

Open in new window

0
 
DS928Author Commented:
The other way doesn't seem to work, so I tried changing the action on the form to call the proper php according to the value of a hidden textbox on the form.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

Tackle projects and never again get stuck behind a technical roadblock.
Join Now