• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 420
  • Last Modified:

Im getting 500 Internal Server Error when using .post() jquery

Im trying to use .post()  in a jquery sumbit form
the ur l= handelSpamDb.php

and I get 500 Internal Server Error
            26ms

$("#"+popup_form_id).submit(function(e) {
                         //   alert("Hello world!");
							//fElement.attr('flag','1');
							e.preventDefault();
						//"mark" the input name =flag as spam 
						    $(":hidden[name='flag']","#"+popup_form_id).val("on");
							fElement.toggle();
							//$.ajax(
							alert($(this).serialize() +"tryinggg");
							$.post(url,$(this).serialize());
								
							
					})

Open in new window

0
Nura111
Asked:
Nura111
  • 13
  • 6
  • 3
2 Solutions
 
Dave BaldwinFixer of ProblemsCommented:
That has to be an error in 'handelSpamDb.php' because jquery does not run on the server.  Do you have an alternate way of testing 'handelSpamDb.php' like a simple HTML form that will POST to it?
0
 
Nura111Author Commented:
the code in theat file was previuosly in a diffrent location wraped by if isset[formSumbit]
and it was working

Do I still need ro access the variables in $_POST see code
$id = $_POST['id'];

$email = $_POST['email'];



$sql= BaseModel::getSqlObject();

$query = "SELECT * FROM BlackList WHERE email_address = '$email'";	

	     

	if (($result=$sql->Query($query)) === FALSE)

      die(ShowError("Server Query Error"));

$num = $result->num_rows;

	   

	//check if email is not already exist in BlackList

	if ($result->num_rows == 0){

   			 $insert_query = "INSERT INTO BlackList(email_address) VALUES ('$email')";

			 

	 if (($result=$sql->Query($insert_query)) === FALSE)

           	die(ShowError("Server Insert Query Error"));

		}

		

		$insert_query =	"UPDATE ServiceRequests SET spam = 1 WHERE id = '$id'";

		if (($result=$sql->Query($insert_query)) === FALSE)

           	die(ShowError("Server Insert Query Error service"));





			die ("ok");

         

	

		

 

		

		}

Open in new window

0
 
Nura111Author Commented:
Does it matter who is the referral page?
0
Get 10% Off Your First Squarespace Website

Ready to showcase your work, publish content or promote your business online? With Squarespace’s award-winning templates and 24/7 customer service, getting started is simple. Head to Squarespace.com and use offer code ‘EXPERTS’ to get 10% off your first purchase.

 
Nura111Author Commented:
the fire bug debug is saying the mistake is in       
jquery.js (line 7950)
0
 
Nura111Author Commented:
Is it ok to gop in the script to $_POST is it suppose to be there after sent it with .post()?
0
 
Dave BaldwinFixer of ProblemsCommented:
The Firebug error is a different subject because Firebug can't tell you about server errors, only javascript and DOM.
0
 
Nura111Author Commented:
Is it ok to go in the refred script to $_POST is it suppose to be there after sent it with .post()?
0
 
Dave BaldwinFixer of ProblemsCommented:
I'm not sure I understand.  If you send the data as a POST like you are showing, then it has to be received in the $_POST array.
0
 
Nura111Author Commented:
Ok so is nyone can help in the server error issue?
0
 
MacAnthonyCommented:
What is the value of url from the post call? Are you sure it's the file that is handling your post values?
0
 
Nura111Author Commented:
Do you mean what I wrote in the question    url = handelSpamDb.php

and yes Im sure I attched the code also
0
 
Nura111Author Commented:
what is the common way im suppose to handle the errors in the jquery submit?
0
 
MacAnthonyCommented:
What I was asking was if we were sure that the value in url is actually the file we expect the request to be made against. The code shown does not show how the 'url' variable is assigned - so I asked.

.post supports using an .error() function to handle when the post is not returned successfully. It would look something like:

$.post(url,$(this).serialize()).error(function() { alert('post failed'); });

Open in new window


Are there any errors that show up in the webserver logs? If this is apache on linux, it may be in /var/log/https/error_log or something but that would depend on the system configuration.
0
 
Nura111Author Commented:
Its on vmware there is only one filr in log folder and it doesnt show anything
0
 
MacAnthonyCommented:
Can you type the page address in the address bar and get it to load without error?
0
 
Nura111Author Commented:
no its not working is well its cant find it but the php file is there in the public folder like all the other ones that I can get access directly by entering the url
0
 
MacAnthonyCommented:
Can you check the permissions of the file? Are they the same as the other files that are working?
0
 
Nura111Author Commented:
yes same pemisiions read and write
0
 
MacAnthonyCommented:
Same file extension? Like the ones working aren't .php and this one .inc or something, right?

There has to be something different, I'm just taking guesses at what they could possibly be.
0
 
Nura111Author Commented:
no there are both .php extention
0
 
MacAnthonyCommented:
And there is nothing in either the apache or php error logs?

I'm kind of at a loss for ideas of what could cause this.
0
 
Nura111Author Commented:
what are the possible location the log file can be?
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 10% Off Your First Squarespace Website

Ready to showcase your work, publish content or promote your business online? With Squarespace’s award-winning templates and 24/7 customer service, getting started is simple. Head to Squarespace.com and use offer code ‘EXPERTS’ to get 10% off your first purchase.

  • 13
  • 6
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now