Solved

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

Posted on 2011-09-28
22
370 Views
Last Modified: 2012-05-12
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
Comment
Question by:Nura111
  • 13
  • 6
  • 3
22 Comments
 
LVL 83

Accepted Solution

by:
Dave Baldwin earned 250 total points
ID: 36719938
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
 

Author Comment

by:Nura111
ID: 36720002
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
 

Author Comment

by:Nura111
ID: 36720039
Does it matter who is the referral page?
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:Nura111
ID: 36720076
the fire bug debug is saying the mistake is in       
jquery.js (line 7950)
0
 

Author Comment

by:Nura111
ID: 36720110
Is it ok to gop in the script to $_POST is it suppose to be there after sent it with .post()?
0
 
LVL 83

Expert Comment

by:Dave Baldwin
ID: 36720144
The Firebug error is a different subject because Firebug can't tell you about server errors, only javascript and DOM.
0
 

Author Comment

by:Nura111
ID: 36720151
Is it ok to go in the refred script to $_POST is it suppose to be there after sent it with .post()?
0
 
LVL 83

Expert Comment

by:Dave Baldwin
ID: 36720166
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
 

Author Comment

by:Nura111
ID: 36720212
Ok so is nyone can help in the server error issue?
0
 
LVL 11

Expert Comment

by:MacAnthony
ID: 36720309
What is the value of url from the post call? Are you sure it's the file that is handling your post values?
0
 

Author Comment

by:Nura111
ID: 36720318
Do you mean what I wrote in the question    url = handelSpamDb.php

and yes Im sure I attched the code also
0
 

Author Comment

by:Nura111
ID: 36720327
what is the common way im suppose to handle the errors in the jquery submit?
0
 
LVL 11

Expert Comment

by:MacAnthony
ID: 36720407
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
 

Author Comment

by:Nura111
ID: 36720437
Its on vmware there is only one filr in log folder and it doesnt show anything
0
 
LVL 11

Expert Comment

by:MacAnthony
ID: 36720454
Can you type the page address in the address bar and get it to load without error?
0
 

Author Comment

by:Nura111
ID: 36906041
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
 
LVL 11

Expert Comment

by:MacAnthony
ID: 36906055
Can you check the permissions of the file? Are they the same as the other files that are working?
0
 

Author Comment

by:Nura111
ID: 36906068
yes same pemisiions read and write
0
 
LVL 11

Expert Comment

by:MacAnthony
ID: 36906134
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
 

Author Comment

by:Nura111
ID: 36906143
no there are both .php extention
0
 
LVL 11

Assisted Solution

by:MacAnthony
MacAnthony earned 250 total points
ID: 36910123
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
 

Author Comment

by:Nura111
ID: 36911311
what are the possible location the log file can be?
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
need help with share buttons 11 65
Question regarding to $.ajax() with type "POST" vs $.post() 4 27
Html split(text) Part2 6 20
web page freezes after ajax post 7 41
Because your company can’t afford for you to make SEO mistakes, you’ll want to ensure you’re taking the right steps each and every time you post a new piece of content. This list of optimization do’s and don’ts can help you become an SEO wizard.
Does your audience prefer people in photos or no people? How can you best highlight what you’re selling? What are your competitors doing, and what can you do that is different and unique from them?  Continue reading to learn how to make your images …
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

685 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question