开发者

how to pass a jquery variable to php

hi there im trying to pass my jquery variable onto php

j query bit

 <script> $(document).ready(function() {
开发者_如何学JAVA
$(function() {
    $( "#tabs" ).tabs().find( ".ui-tabs-nav" );
});

$("#resizable").resizable({ maxWidth: 500,  minWidth: 250 ,handles:'e', grid: [1, 1] } );
 var txt =$("#resizable").width() * 2;  $("#test").text('Template Width: ' + txt + 'px');
 $("#resizable").resize(function() {
     txt = $("#resizable").width() * 2;
      $("#test").text('Template Width:' + txt + 'px'); 

what i want to do is call my txt variable into php for example

<?php $templatewidth = (myjquery variable txt) ;?>


You'd need to make an XHR to the server to send that variable to PHP.

Look at the jQuery AJAX methods.


  1. PHP runs on the server, generates some output.
  2. The server delivers that output to the browser
  3. The browser runs any client side JavaScript in the page

It is too late to send data back to the instance of the PHP program that generated the page.

You can send new data by making an HTTP request (e.g. via XMLHttpRequest), get a response in JS and then handle that new data in JS.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜