PDA

View Full Version : AJAX interaction into a PHP site using jQuery and the jQueryUI framework.



megha_3000
05-21-2013, 10:13 AM
Hello Everybody,

Can anyone tell me, why editing is not working with this code ?

This is the link :
http://jeremydorn.blogspot.com/2011/02/simple-ajax-with-jqueryui-and-php.html

When i incorporate this code. Than it displays ok. But when i want to edit the
information it's not working.

In addition to this it will be really very helpful if deletion can also be done with
this code.

Thanking You
Megha

traq
05-22-2013, 07:57 AM
when i want to edit the information it's not working...

"it's not working" is very useless information. If it were working, you wouldn't be trying to fix it.

What is going on? which part are you having a problem with? what do you expect to happen? what happens instead? what error messages do you get? We can't help you if you don't explain your problem.

Your question is unclear.
Please provide more information, and be as specific as possible.
What do you want to accomplish? What have you already tried? What problems did you encounter?
Please be sure that you have included all relevant code and/or a link to the page in question.
You might also consider making a reduced test case (http://css-tricks.com/reduced-test-cases/) using an online tool like jsfiddle (http://jsfiddle.net)

megha_3000
05-22-2013, 08:53 AM
The problem is it has hidden form. When i click on edit their it gives data from the database.
But the problem happens when i submit that edited data. The edited data doesn't
make any change in database.

And like edit if deletion of records can be added with the code then it will be very helpful for me.

Please help me.

traq
05-22-2013, 07:41 PM
The problem is it has hidden form. When i click on edit their it gives data from the database.
But the problem happens when i submit that edited data. The edited data doesn't
make any change in database. So, the data you enter into the form doesn't make it to the database?

What does happen when you submit the form - do you get a response? an error message?

Check your javascript console ([CTRL]+[SHIFT]+[J] in Chrome, for example) to see if your ajax call is succeeding (or even being sent, at all).

If it is, you can add something like exit( var_dump( $_POST ) ); in the edit.php file to see if the data is arriving correctly.

Some things to consider about the tutorial you're following:

die() is a very, very bad way to handle errors. It just stops everything right where it is and, well, dies. This usually results in a broken page, because you don't finish outputting the HTML markup. It is also very difficult to recover from - you can't try to fix anything after this point, sometimes the links/menus on the page won't work either.

Likewise, it is better to do PHP First (http://www.dynamicdrive.com/forums/entry.php?267-Every-PHP-Tutorial-Is-Wrong), before outputting anything to the webpage. If this tutorial were designed that way, for example, then using die() would be less problematic because there would never be a broken page.

The tutorial has several other basic errors, including using PHP comments in HTML output (which, among other things, will break the JSON response edit.php tries to send you).

This tutorial has almost *zero* error-checking. For example, it sends queries to MySQL and then continues on, assuming everything worked, without checking. You'll get the same response from this script whether the UPDATE succeeds or fails; there's no way to tell if it worked without actually looking at the database.

You should always validate user input - this tutorial makes a basic attempt at sanitization, but passes submitted data to the database unchanged otherwise.

Speaking of UPDATE, this script gives *anyone* access to update your database. If this is anything more than a learning experience, on a non-public host, it really needs authentication of some kind (even if it's just submitting a password along with the UPDATE data).

The mysql_*() functions are deprecated. You should not be learning how to use them: learn using mysqli (http://php.net/mysqli) or PDO (http://php.net/pdo) instead.
(This tutorial was written about two years ago - ext/mysql was very outdated even then. ext/mysqli has been the recommended extension for MySQL since June 2004.)


**********************************

And like edit if deletion of records can be added with the code then it will be very helpful for me.
I'd recommend understanding the code and getting it to work "as-is" before trying to add features.
If you're just asking for someone to do it for you, you can post in the Paid Work forum (http://www.dynamicdrive.com/forums/forumdisplay.php?30-General-Paid-Work-Requests).

megha_3000
05-26-2013, 06:05 AM
So, the data you enter into the form doesn't make it to the database?

Yes it is.


What does happen when you submit the form - do you get a response? an error message?

No i don't get anything neither an error message nor a response.



Check your javascript console ([CTRL]+[SHIFT]+[J] in Chrome, for example) to see if your ajax call is succeeding (or even being sent, at all).

It shows some error like:

Failed to load resource: the server responded with a status of 404 (Not Found) http://localhost/images/jquery_ui/ui-bg_highlight-soft_100_eeeeee_1x100.png
GET http://localhost/images/jquery_ui/ui-bg_diagonals-thick_20_666666_40x40.png 404 (Not Found) jquery-1.4.4.min.js:166
GET http://localhost/images/jquery_ui/ui-bg_gloss-wave_35_f6a828_500x100.png 404 (Not Found) jquery-1.4.4.min.js:20
GET http://localhost/images/jquery_ui/ui-icons_ffffff_256x240.png 404 (Not Found) jquery-1.4.4.min.js:20
GET http://localhost/images/jquery_ui/ui-bg_glass_100_f6f6f6_1x400.png 404 (Not Found) jquery-1.4.4.min.js:20
GET http://localhost/images/jquery_ui/ui-bg_glass_100_fdf5ce_1x400.png 404 (Not Found) jquery-1.4.4.min.js:49
GET http://localhost/images/jquery_ui/ui-bg_glass_65_ffffff_1x400.png 404 (Not Found) jquery-1.4.4.min.js:129

But it seems that these are image missing.


If it is, you can add something like exit( var_dump( $_POST ) ); in the edit.php file to see if the data is arriving correctly.

When i did this the submit button of form didn't work. But gives an still look.


**********************************


I'd recommend understanding the code and getting it to work "as-is" before trying to add features.

Yes i want to make the script works too. So please help me.

megha_3000
05-26-2013, 10:43 AM
At last it is solved Thanks ALLAH and thank you all. The code at line 52 where written idid will be just only id.