?
Solved

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

Posted on 2011-09-28
22
Medium Priority
?
385 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 13
  • 6
  • 3
22 Comments
 
LVL 84

Accepted Solution

by:
Dave Baldwin earned 1000 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
Is Your Team Achieving Their Full Potential?

74% of employees feel they are not achieving their full potential. With Linux Academy, not only will you strengthen your team's core competencies but also their knowledge of of the newest IT topics.

With new material every week, we'll make sure that you stay ahead of the game.

 

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 84

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 84

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 1000 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

Looking for a new Web Host?

Lunarpages' assortment of hosting products and solutions ensure a perfect fit for anyone looking to get their vision or products to market. Our award winning customer support and 30-day money back guarantee show the pride we take in being the industry's premier MSP.

Question has a verified solution.

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

CTAs encourage people to do something specific to show interest in your company, product or service. Keep reading to learn why CTAs should always be thought of as extremely important, albeit small, sections of websites.
When it comes to security, close monitoring is a must. According to WhiteHat Security annual report, a substantial number of all web applications are vulnerable always. Monitis offers a new product - fully-featured Website security monitoring and pr…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

718 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