PDA

View Full Version : سوال: ارسال مختصات



ravand
شنبه 13 اسفند 1390, 12:06 عصر
به اين كد نگاه كنيد:

<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript">
jQuery(document).ready(function(){
$("#asb").click(function(e){
var x = e.pageX - this.offsetLeft;
var y = e.pageY - this.offsetTop;
$.post("http://localhost/shat/shatranj.php?x=x&y=y", function(data) {
alert("Data Loaded: " + data);
});

});
});
</script>
من مقادير متغيير هاي x و y رو به اين خط دادم .

http://localhost/shat/shatranj.php?x=x&y=y
ولي به جاي مقدار مختصات كه دو تا عدد هست براي من خود x‌و y رو ارسال ميكنه .
مشكل كار من چيه؟
متشكرم.

mehdi.mousavi
شنبه 13 اسفند 1390, 12:16 عصر
سلام.
جای این بخش از کد:

$.post("http://localhost/shat/shatranj.php?x=x&y=y", function

اینو بنویسید:

$.post('http://localhost/shat/shatranj.php?x=' + x + '&y=' + y, function

موفق باشید.