Go Back   CodingForums.com > :: Client side development > JavaScript programming > Ajax and Design

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 07-18-2012, 08:17 AM   PM User | #1
maria111
New to the CF scene

 
Join Date: Jul 2012
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
maria111 is an unknown quantity at this point
Ajax call not working

Hi ,

I am totally new to programming in javescript .My purpose is to call a python file in javascript .The python script inturn calls a database function .Javascript acts as a web interface to insert data into the postgres db .

There are several fields (string and numbers) in the form and a submit button . After entering data in the form and when the user presses the 'submit' button the main.js makes the follwing Ajax call .But it is not working.

The call is

[code]
function submitForm(event)
{
name =document.getElementById("name");
Location=document.getElementById("Location");
if(this.checkFields(name,Location))
{
var u = 'http://url/test.py'
var dataStr = 'name=' +name.value + '&Location=' +Location.value
$.ajax({
url: u,
datatype: 'xml',
data: dataStr,
type: 'POST',
success: function(xml){
name=$("name",xml).text();
Location=$("Location",xml).text();
var status = $("result",text).find('status').text()
return checkstatus(status);
}
});
}

function checkstatus(status)
{
if(status == "Success" )
{
clearFields
} else{
alert("Enter valid values")
}
}

[code]
The problem is the no insertion of data happens into the database and the xml file is empty .

Even though all the values are provided into the form it always goes to 'Enter valid values' .

And in the python file there is a statement like
print "Content-type:text/xml\r\n\r\n"
Before the database conenction is closed the following sttaement is print from the python file

[code in python]
print '<result>'
if au == True
print '<status>Success</status>'
else:
print '<status>Fail</status>'
print '</result>'

[code in python]

I am trying this in a safari browser .This is urgent .Any help is truly appreciated .

And when I execute the URL in the variable u its working fine and data is getting inserted into the database .Only when I am inserting from the form I have a problem .



Thanks
maria111 is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 12:52 PM.


Advertisement
Log in to turn off these ads.