Ajax PHP JavaScript
foreach ($account as $key = $value)
{
?>
');" >
}
else{
?>
');" >
function Xingxing (id,name) {
$.ajax ({
Type: "POST",
URL: " ",
ProcessData: "false",
Data: "n=" + math.random () + "&fn=" + Escape (ID) + "&starflag=" + Escape (name) + "",
Success:function (msg) {
var msg = $.trim (msg);
Switch (msg) {
Case "200":
Location.replace (LOCATION.HREF);
Case "110"://Re-login
Location.replace (LOCATION.HREF);
Case "120"://Change Password
Location.replace (LOCATION.HREF);
Break
Default
Alert ("failure");
Location.replace (LOCATION.HREF);
Break
}
}
});
}
------------------------------------------------------------------------------
My problem is to call the Ajax after the direct replacement of the image does not need to refresh the page, the prawn help, online, etc.
Reply to discussion (solution)
You are not Location.replace (LOCATION.HREF) in the return event of Ajax; , huh?
This is of course to refresh the page
You are not Location.replace (LOCATION.HREF) in the return event of Ajax; , huh?
This is of course to refresh the page
----------------------------------------------
I can block it, and it will refresh automatically.
Switch whole paragraph Delete
Switch whole paragraph Delete
------------------------
Yes, prawn, please code. Thank you!
This is of course to refresh the page
---------------------------------------
Notice is
in the following code is a loop to display the content, click on a picture is not the ID also passed it, Otherwise the click does not reflect
!--? php
foreach ($account as $key + $value)
{
?>
The status of the!--picture 1 show 2 hidden -->
!--? php if ($value [' starflag '] = = 1) {?-->
'); " >
!--here to replace the picture is the loop ID is also to be passed to JS inside it?-->
!--? php
}
else{
?>
'); " >
!--? php}?-->
!--? php}?-->
You are not Location.replace (LOCATION.HREF) in the return event of Ajax; , huh?
This is of course to refresh the page
function Xingxing (id,name) {
$.ajax ({
Type: "POST",
URL: " ",
ProcessData: "false",
Data: "n=" + math.random () + "&fn=" + Escape (ID) + "&starflag=" + Escape (name) + "",
Success:function (msg) {
var msg = $.trim (msg);
$ ("#img_b"). attr ("src", "images/star01.gif");
}
});
}
-----------------------------------
Do not know how to achieve, moderator Badaoxiangchu
$ ("#img_b"). attr ("src", "/themes/default/images/star01.gif");
What is the IM attribute of your img tag?
$ ("#img_b"). attr ("src", "/themes/default/images/star01.gif");
What is the IM attribute of your img tag?
I don't know, I dropped it.
Replacing the attribute with SRC is generally not a problem
If you don't get the right results,
First check the execution to this sentence is not this sentence before there is a mistake
Replacing the attribute with SRC is generally not a problem
If you don't get the right results,
First check the execution to this sentence is not this sentence before there is a mistake
When updating a piece of data, the one above corresponds to whether the ID is updated
Don't know what you're going to do?
Since jquery is used, it's time to use the traditional jquery notation.
PHP section
"Name="
"id="
"/>" name= "
id="
JS section
$ (function () { $ (". IMG"). Click (function () { $ (this). Children (). Toggle (); $.post ("
", { n:math.random (), Fn:escape ($ (this). attr (' id ')), Starflag:escape ($ (this). attr (' name ') }, function (msg) { //other processing you need } );});
It's the same with $.ajax.